假設您正在爲項目使用.pro
文件,則需要從RESOURCES
列表中刪除資源文件。如果您仍然希望將其列入您的項目中,則可以使用OTHER_FILES
。
前:
RESOURCES += file1.qrc file2.qrc
後:
RESOURCES += file2.qrc
OTHER_FILES += file1.qrc
如果你想走得更遠了一步,你可以自動的QRC文件編譯:
RCC_BINARY_SOURCES += file1.qrc
asset_builder.commands = $$[QT_HOST_BINS]/rcc -binary ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} -no-compress
asset_builder.depend_command = $$[QT_HOST_BINS]/rcc -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
asset_builder.input = RCC_BINARY_SOURCES
asset_builder.output = $$OUT_PWD/$$DESTDIR/${QMAKE_FILE_IN_BASE}.qrb
asset_builder.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += asset_builder
OTHER_FILES += $$RCC_BINARY_SOURCES
它工作,謝謝! –