QtCore and Settings ?
-
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 ) -
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 )@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 addimport Qt.labs.settingson the top of the QML file.
Unless needed for other stuff,import QtCorecan go.
Please mind, that the settings module initialization is bound to fail, unless the application identifiersorganizationNameandorganizationDomainhave been set. -
@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 addimport Qt.labs.settingson the top of the QML file.
Unless needed for other stuff,import QtCorecan go.
Please mind, that the settings module initialization is bound to fail, unless the application identifiersorganizationNameandorganizationDomainhave been set.@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...
-
@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...
@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. -
@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.@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.
-
@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.
@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.