Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Usage of QtQuickCompiler in Qt6
Forum Updated to NodeBB v4.3 + New Features

Usage of QtQuickCompiler in Qt6

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zhavok
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • -vix-- Offline
      -vix-- Offline
      -vix-
      wrote on last edited by
      #2

      Hi @Zhavok ,
      you could try to replace the qtquick_compiler_add_resources with qt6_add_resources and remove the find_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)

      T 1 Reply Last reply
      0
      • -vix-- -vix-

        Hi @Zhavok ,
        you could try to replace the qtquick_compiler_add_resources with qt6_add_resources and remove the find_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)

        T Offline
        T Offline
        tonghao.yuan
        wrote on last edited by
        #3

        @vix Hi vix, have QtSupport confirmed this?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved