[Development] QML Singleton

Steve Gold steveg2357 at gmail.com
Sun Mar 9 21:59:15 CET 2014


1. Can a QML singleton contain signals and functions that are accessed by other QML types or just properties?

2. I specified
       pragma singleton
as the first line in MySingleton.qml and have
     property string myText: “”
in MySingleton.qml, specified
     import “.”
at the top of main.qml, and added qml in their common directory with
     singleton MySingleton MySingleton.qml

When I have
     property string mySingletonText: MySingleton.myText
in main.qml I get the error
       qrc:/qml/main.qml:11: ReferenceError: MySingleton is not defined
but MySingleton.qml is specified in my .pro and .qrc files.

When I have
     MySingleton{
       id: singleton
     }
in main.qml I get the error
     qrc:/qml/MySingleton.qml:1:1: pragma Singleton used with a non composite singleton type MySingleton
I tried this because I assumed (perhaps mistakenly) that this would be the way to access signals and functions of a singleton.

Any help would be appreciated.

Thanks.

Steve

BTW, is a different group more appropriate. In addition, should I post this in the forums or use a group email?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140309/a62c088d/attachment.html>


More information about the Development mailing list