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. QtCore and Settings ?
Forum Updated to NodeBB v4.3 + New Features

QtCore and Settings ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 4 Posters 1.9k Views 1 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.
  • B Offline
    B Offline
    BVladimir
    wrote on last edited by
    #1

    The qml below works fine in Qt Creator but does not work in CLion - error: "module "QtCore" is not installed" (import QtQuick and import Qt.labs.settings instead QtCore - ok). I suspect that it's about the settings in CMakeLists.txt . What should I add ?

    import QtCore
    import QtQuick
    
    Window {
        id: window
    
        width: 800
        height: 600
    
        Settings {
            property alias x: window.x
            property alias y: window.y
            property alias width: window.width
            property alias height: window.height
        }
    }
    

    CMakeLists.txt:

    ...
    find_package(Qt6 6.5 REQUIRED COMPONENTS Core Quick Qml Gui QuickControls2)
    qt_standard_project_setup(REQUIRES 6.5)
    set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/Project_sources/QML ${CMAKE_BINARY_DIR}/imports CACHE STRING "" FORCE)
    ...
    target_link_libraries(Quik_Qt_Robot PUBLIC
            Qt6::Core
            Qt6::Quick
            Qt6::Qml
            Qt6::Gui
            Qt6::QuickControls2        
            )
    
    Axel SpoerlA 1 Reply Last reply
    0
    • B BVladimir

      The qml below works fine in Qt Creator but does not work in CLion - error: "module "QtCore" is not installed" (import QtQuick and import Qt.labs.settings instead QtCore - ok). I suspect that it's about the settings in CMakeLists.txt . What should I add ?

      import QtCore
      import QtQuick
      
      Window {
          id: window
      
          width: 800
          height: 600
      
          Settings {
              property alias x: window.x
              property alias y: window.y
              property alias width: window.width
              property alias height: window.height
          }
      }
      

      CMakeLists.txt:

      ...
      find_package(Qt6 6.5 REQUIRED COMPONENTS Core Quick Qml Gui QuickControls2)
      qt_standard_project_setup(REQUIRES 6.5)
      set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/Project_sources/QML ${CMAKE_BINARY_DIR}/imports CACHE STRING "" FORCE)
      ...
      target_link_libraries(Quik_Qt_Robot PUBLIC
              Qt6::Core
              Qt6::Quick
              Qt6::Qml
              Qt6::Gui
              Qt6::QuickControls2        
              )
      
      Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      @BVladimir
      It looks like CLion compiles against another Qt version than Qt Creator does.
      It just wonder why it configures at al,l since the CMakeLists requires 6.5.
      Anyway, nothing needs to be done in CMakeLists.txt.
      Just add import Qt.labs.settingson the top of the QML file.
      Unless needed for other stuff, import QtCore can go.
      Please mind, that the settings module initialization is bound to fail, unless the application identifiers organizationName and organizationDomain have been set.

      Software Engineer
      The Qt Company, Oslo

      B 1 Reply Last reply
      0
      • Axel SpoerlA Axel Spoerl

        @BVladimir
        It looks like CLion compiles against another Qt version than Qt Creator does.
        It just wonder why it configures at al,l since the CMakeLists requires 6.5.
        Anyway, nothing needs to be done in CMakeLists.txt.
        Just add import Qt.labs.settingson the top of the QML file.
        Unless needed for other stuff, import QtCore can go.
        Please mind, that the settings module initialization is bound to fail, unless the application identifiers organizationName and organizationDomain have been set.

        B Offline
        B Offline
        BVladimir
        wrote on last edited by
        #3

        @Axel-Spoerl said in QtCore and Settings ?:

        @BVladimir
        It looks like CLion compiles against another Qt version than Qt Creator does.
        It just wonder why it configures at al,l since the CMakeLists requires 6.5.

        No, I have only one version - qt 6.5. It looks like I'll have to stay with the outdated Qt.labs.settings...

        JoeCFDJ 1 Reply Last reply
        0
        • B BVladimir

          @Axel-Spoerl said in QtCore and Settings ?:

          @BVladimir
          It looks like CLion compiles against another Qt version than Qt Creator does.
          It just wonder why it configures at al,l since the CMakeLists requires 6.5.

          No, I have only one version - qt 6.5. It looks like I'll have to stay with the outdated Qt.labs.settings...

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          @BVladimir
          https://doc.qt.io/qt-6/qml-qt-labs-settings-settings.html#details
          Note: This type is made available by importing the Qt.labs.settings module. Types in the Qt.labs module are not guaranteed to remain compatible in future versions.

          B 1 Reply Last reply
          1
          • JoeCFDJ JoeCFD

            @BVladimir
            https://doc.qt.io/qt-6/qml-qt-labs-settings-settings.html#details
            Note: This type is made available by importing the Qt.labs.settings module. Types in the Qt.labs module are not guaranteed to remain compatible in future versions.

            B Offline
            B Offline
            BVladimir
            wrote on last edited by
            #5

            @JoeCFD said in QtCore and Settings ?:

            Note: This type is made available by importing the Qt.labs.settings module. Types in the Qt.labs module are not guaranteed to remain compatible in future versions.

            I read this so I wanted to switch to QtCore.

            B 1 Reply Last reply
            1
            • B BVladimir

              @JoeCFD said in QtCore and Settings ?:

              Note: This type is made available by importing the Qt.labs.settings module. Types in the Qt.labs module are not guaranteed to remain compatible in future versions.

              I read this so I wanted to switch to QtCore.

              B Offline
              B Offline
              Bob64
              wrote on last edited by
              #6

              @BVladimir the labs version is the only one available to use in QML. You could maybe write your own QML wrapper around the C++ QSettings class in QtCore, but I suspect it would not end up being much different from the labs version.

              TBH, this labs stuff in QML is a bit annoying. The way it is described in the documentation makes one quite nervous to rely on it, but on the other hand there seems to have been no movement on it for years. It neither seems to get removed nor promoted to "real" library status.

              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