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. RCC Warning When Using CMake

RCC Warning When Using CMake

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 820 Views 3 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.
  • O Offline
    O Offline
    oa_flo
    wrote on last edited by
    #1

    Hi, first of all thanks for looking at this post, any help is appreciated. I encountered this problem with a larger project but I have been able to reproduce it with a simple project.

    When I import QtQuick.Controls, I get the following warning:

    Warning: QtQuick.Controls uses optional imports which are not supported. Some types might not be found. [import]
    

    My goal is to solve this warning. Note that the application runs fine. But in a large project, the warnings add a lot of noise.

    Setup
    I am using:

    • Qt 6.5.0
    • CMake 3.22.3
    • QtCreator 10.0.1
    • Ubuntu 22

    I am using a simple project that I created with QtCreator's wizard and modified it to reproduce the issue.

    CMakeLists.txt:

    cmake_minimum_required(VERSION 3.16)
    
    project(test_qt6 VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    # find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
    find_package(QT NAMES Qt6 COMPONENTS Qml Quick QuickControls2)
    find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick QuickControls2)
    
    qt_standard_project_setup(REQUIRES 6.5)
    
    set(QUICK_CONTROLS "QtQuick.Controls.Basic")
    
    set_source_files_properties(
            TestSingleton.qml PROPERTIES
            QT_QML_SINGLETON_TYPE TRUE)
    
    qt_add_executable(apptest_qt6
        main.cpp
    )
    
    qt_add_qml_module(apptest_qt6
        URI test_qt6
        VERSION 1.0
        IMPORTS ${QUICK_CONTROLS}
        QML_FILES Main.qml TestSingleton.qml
    )
    
    set_target_properties(apptest_qt6 PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_link_libraries(apptest_qt6
        PRIVATE Qt6::Core Qt6::Quick
    )
    
    install(TARGETS apptest_qt6
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    

    Main.qml:

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Window
    
    Window {
        visible: true
        width: 801
        height: 1280
        Item {
            anchors.fill: parent
            Rectangle {
                id: rectangle
                anchors.fill: parent
                color: "red"
    
                Button {
                    text: "TEST ME"
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                }
            }
        }
    }
    

    main.cpp:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
            &app, []() { QCoreApplication::exit(-1); },
            Qt::QueuedConnection);
        engine.loadFromModule("test_qt6", "Main");
    
        return app.exec();
    }
    

    When I compile I get the warning posted earlier. Here is the full compile output (I removed sensitive info):

    13:01:38: Running steps for project test_qt6...
    13:01:38: Starting: "/usr/local/bin/cmake" --build /home/*****/qt_projects/build-test_qt6-Desktop_Qt_6_5_0_GCC_64bit-Debug --target all
    [1/7 163.2/sec] Generating test_qt6/Main.qml
    [2/7 40.2/sec] Running qmlimportscanner for apptest_qt6
    [3/7 55.1/sec] Running rcc for resource apptest_qt6_raw_qml_0
    [4/7 30.0/sec] Generating .rcc/qmlcache/apptest_qt6_Main_qml.cpp
    Warning: Main.qml:2:1: Warnings occurred while importing module "QtQuick.Controls": [import]
    import QtQuick.Controls
    ^^^^^^
    ---
    Warning: QtQuick.Controls uses optional imports which are not supported. Some types might not be found. [import]
    ---
    
    Info: Main.qml:2:1: Unused import [unused-imports]
    import QtQuick.Controls
    ^^^^^^
    [5/7 32.1/sec] Building CXX object CMakeFiles/apptest_qt6.dir/.rcc/qrc_apptest_qt6_raw_qml_0.cpp.o
    [6/7 3.4/sec] Building CXX object CMakeFiles/apptest_qt6.dir/.rcc/qmlcache/apptest_qt6_Main_qml.cpp.o
    [7/7 3.2/sec] Linking CXX executable apptest_qt6
    13:01:40: The process "/usr/local/bin/cmake" exited normally.
    13:01:40: Elapsed time: 00:02.
    

    I found this blog post, but it did not seam to work in my case.

    In my larger project, I have several other warnings that appear to comme from RCC. One of my guess is that RCC is missing info that I should maybe set from CMake, but it is only a guess.

    Any help is greatly appreciated. Thanks.

    mzimmersM 1 Reply Last reply
    2
    • O oa_flo

      Hi, first of all thanks for looking at this post, any help is appreciated. I encountered this problem with a larger project but I have been able to reproduce it with a simple project.

      When I import QtQuick.Controls, I get the following warning:

      Warning: QtQuick.Controls uses optional imports which are not supported. Some types might not be found. [import]
      

      My goal is to solve this warning. Note that the application runs fine. But in a large project, the warnings add a lot of noise.

      Setup
      I am using:

      • Qt 6.5.0
      • CMake 3.22.3
      • QtCreator 10.0.1
      • Ubuntu 22

      I am using a simple project that I created with QtCreator's wizard and modified it to reproduce the issue.

      CMakeLists.txt:

      cmake_minimum_required(VERSION 3.16)
      
      project(test_qt6 VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      # find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
      find_package(QT NAMES Qt6 COMPONENTS Qml Quick QuickControls2)
      find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick QuickControls2)
      
      qt_standard_project_setup(REQUIRES 6.5)
      
      set(QUICK_CONTROLS "QtQuick.Controls.Basic")
      
      set_source_files_properties(
              TestSingleton.qml PROPERTIES
              QT_QML_SINGLETON_TYPE TRUE)
      
      qt_add_executable(apptest_qt6
          main.cpp
      )
      
      qt_add_qml_module(apptest_qt6
          URI test_qt6
          VERSION 1.0
          IMPORTS ${QUICK_CONTROLS}
          QML_FILES Main.qml TestSingleton.qml
      )
      
      set_target_properties(apptest_qt6 PROPERTIES
          MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
          MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
          MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
          MACOSX_BUNDLE TRUE
          WIN32_EXECUTABLE TRUE
      )
      
      target_link_libraries(apptest_qt6
          PRIVATE Qt6::Core Qt6::Quick
      )
      
      install(TARGETS apptest_qt6
          BUNDLE DESTINATION .
          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
      )
      

      Main.qml:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Window
      
      Window {
          visible: true
          width: 801
          height: 1280
          Item {
              anchors.fill: parent
              Rectangle {
                  id: rectangle
                  anchors.fill: parent
                  color: "red"
      
                  Button {
                      text: "TEST ME"
                      anchors.verticalCenter: parent.verticalCenter
                      anchors.horizontalCenter: parent.horizontalCenter
                  }
              }
          }
      }
      

      main.cpp:

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
              &app, []() { QCoreApplication::exit(-1); },
              Qt::QueuedConnection);
          engine.loadFromModule("test_qt6", "Main");
      
          return app.exec();
      }
      

      When I compile I get the warning posted earlier. Here is the full compile output (I removed sensitive info):

      13:01:38: Running steps for project test_qt6...
      13:01:38: Starting: "/usr/local/bin/cmake" --build /home/*****/qt_projects/build-test_qt6-Desktop_Qt_6_5_0_GCC_64bit-Debug --target all
      [1/7 163.2/sec] Generating test_qt6/Main.qml
      [2/7 40.2/sec] Running qmlimportscanner for apptest_qt6
      [3/7 55.1/sec] Running rcc for resource apptest_qt6_raw_qml_0
      [4/7 30.0/sec] Generating .rcc/qmlcache/apptest_qt6_Main_qml.cpp
      Warning: Main.qml:2:1: Warnings occurred while importing module "QtQuick.Controls": [import]
      import QtQuick.Controls
      ^^^^^^
      ---
      Warning: QtQuick.Controls uses optional imports which are not supported. Some types might not be found. [import]
      ---
      
      Info: Main.qml:2:1: Unused import [unused-imports]
      import QtQuick.Controls
      ^^^^^^
      [5/7 32.1/sec] Building CXX object CMakeFiles/apptest_qt6.dir/.rcc/qrc_apptest_qt6_raw_qml_0.cpp.o
      [6/7 3.4/sec] Building CXX object CMakeFiles/apptest_qt6.dir/.rcc/qmlcache/apptest_qt6_Main_qml.cpp.o
      [7/7 3.2/sec] Linking CXX executable apptest_qt6
      13:01:40: The process "/usr/local/bin/cmake" exited normally.
      13:01:40: Elapsed time: 00:02.
      

      I found this blog post, but it did not seam to work in my case.

      In my larger project, I have several other warnings that appear to comme from RCC. One of my guess is that RCC is missing info that I should maybe set from CMake, but it is only a guess.

      Any help is greatly appreciated. Thanks.

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      @oa_flo have you tried adding:

      set(CMAKE_AUTORCC ON)
      

      To your CMakeList.txt file?

      1 Reply Last reply
      0
      • KH-219DesignK Offline
        KH-219DesignK Offline
        KH-219Design
        wrote on last edited by
        #3

        I am still "stuck" (for the time being) on projects using Qt5 and not Qt6. So everything I say here is nothing more than educated guessing.

        From the looks of it, it seems you cannot avoid that warning unless you can remove your reliance on QtQuick.Controls.

        The warning is coming from here:
        https://github.com/qt/qtdeclarative/blob/dev/src/qmlcompiler/qqmljsimporter.cpp#L304

        Which was added here (with lots of discussion, but between Qt developers that have a lot more shared understanding of QML and legacy issues):
        https://codereview.qt-project.org/c/qt/qtdeclarative/+/394363

        It seems to have something to do with the migration/refactoring from Qt5 to Qt6, and the fact that QtQuick.Controls is "old."

        You might be able to chase down more information if you keep following the breadcrumbs. I'd be interested to hear if you get a resolution. (I'll watch this forum thread.)

        www.219design.com
        Software | Electrical | Mechanical | Product Design

        1 Reply Last reply
        1

        • Login

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