QML singleton in CMake (Qt 6.2)
-
In the documentation for Qt 6.2+, it gives an example of how to create a singleton: https://doc.qt.io/qt-6/qt-target-qml-sources.html
The CMake code:
set_source_files_properties(FunnySingleton.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE )results in qmldir:
singleton FunnySingleton 2.0 FunnySingleton.qmlHow could I get it to put the following in qmldir instead:
singleton FS 2.0 FunnySingleton.qmli.e. how do I rename it so that I can reference its properties elsewhere in QML as
FS.xxxinstead ofFunnySingleton.xxx? -
@paulmasri said in QML singleton in CMake (Qt 6.2):
i.e. how do I rename it so that I can reference its properties elsewhere in QML as FS.xxx instead of FunnySingleton.xxx?
https://doc.qt.io/qt-6/qt-target-qml-sources.html says:
the name of the type itself can also be overridden using the QT_QML_SOURCE_TYPENAME property.
so writing should achieve what you want:
set_source_files_properties(FunnySingleton.qml PROPERTIES QT_QML_SOURCE_TYPENAME FS QT_QML_SINGLETON_TYPE TRUE )