Usage of QtQuickCompiler in Qt6
Unsolved
QML and Qt Quick
-
I tried to use the QtQuickCompiler the first time, so I looked in the Qt docs. (https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html). But if I call qtquick_compiler_add_resources it shows me:
Unknown CMake command "qtquick_compiler_add_resources".
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.14) project(ProtoPaste LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_PREFIX_PATH "C:/Qt/6.0.0/msvc2019_64/lib/cmake") set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource.rc") option(CLIP_TESTS OFF) option(CLIP_EXAMPLES OFF) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick QuickControls2 Widgets Qt6QuickCompiler REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick QuickControls2 Widgets REQUIRED) qtquick_compiler_add_resources(RESOURCES src/qml.qrc src/images.qrc ) set(PROJECT_SOURCES src/main.cpp src/availableElement.cpp src/selectedElement.cpp src/availableElementsModel.cpp src/selectedElementsModel.cpp ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(ProtoPaste WIN32 ${PROJECT_SOURCES} ${RESOURCES} ${APP_ICON_RESOURCE_WINDOWS} ) else() add_executable(ProtoPaste WIN32 ${PROJECT_SOURCES} ${RESOURCES} ${APP_ICON_RESOURCE_WINDOWS} ) endif() add_subdirectory(dependencies) target_include_directories(ProtoPaste PRIVATE ${clip_SOURCE_DIR}) target_compile_definitions(ProtoPaste PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_link_libraries(ProtoPaste PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::QuickControls2 Qt${QT_VERSION_MAJOR}::Widgets clip)
What am I doing wrong?
-
Hi @Zhavok ,
you could try to replace theqtquick_compiler_add_resources
withqt6_add_resources
and remove thefind_package
directive.
In Qt5 the QtQuickCompiler was in charge to generate cache for the QML (see here).
However, in QT6 seems (I ask to the QtSupport, wait for someone confirming it) that the cache will be automatically generated (see here)