Re: [Interest] QML global variables?
Yeah, you're right. I was talking about using a JS dictionary for property value. ex: property var myJSDictionary: ({ 'key1': myItemId, 'key2': myItem2 }) or property var myEmptyJSDictionary: ({}) Since you had a single property for appData used by multiple object I was thinking it could have been your use case. In the case of a dictionary you need to merge setting and assign it again to take effect and emit the change. But This is not directly related to your question. On Tue, Jan 6, 2015 at 2:24 PM, Jason H wrote: > Many thanks. > > What do you mean by "Note: If your data are js dictionary make sure to > merge left or right the data before assignation." > If I use "*property var screenData: windowsUniqueId_.appData" then it > should create a property binding, and merging should not be needed, > correct?* > > > *Sent:* Tuesday, January 06, 2015 at 2:14 PM > *From:* "Jérôme Godbout" > *To:* "Jason H" > *Cc:* "interest@qt-project.org" > *Subject:* Re: [Interest] QML global variables? > You can try to use a singleton, seem like what you need. > > Inside qmldir: > *singleton Settings 1.0 Settings.qml* > > At the beginning of Settings.qml > *pragma Singleton* > *// import goes here* > *QObject* > *{* > *property var appData* > *}* > Then you can use the *Settings.appData* > > Or you can use the cascading into scope. Each your screen should be able > to reach the Windows id (make sure to never use it again) > > *Main.qml* > *Window * > *{ * > * id: windowsUniqueId_* > * property var appData* > * Screen1 {}* > * Screen2 {}* > *}* > > *Screen1,2,3.qml:* > *Rectangle* > *{* > * property var screenData: windowsUniqueId_.appData* > *}* > > Note: If your data are js dictionary make sure to merge left or right the > data before assignation. > > On Tue, Jan 6, 2015 at 2:02 PM, Jason H wrote: >> >> What is the proper way to declare a dynamic global? >> >> Currently my app is set up with >> main.qml: >> Window { >> property var AppData; >> Screen1 { onEnter: { screen1.screenData = appData.screen1 }, onExit: { >> appData.screen1 = screen1.screenData }} >> Screen2 { onEnter: { screen2.screenData = appData.screen2 }, onExit: { >> appData.screen2 = screen2.screenData }} >> Screen3 { onEnter: { screen3.screenData = appData.screen3 }, onExit: { >> appData.screen3 = screen3.screenData }} >> } >> >> Screen1,2,3.qml: >> Rectangle { >> property var screenData; >> } >> >> I'd like to just have the screens and Window reference the same variable >> so I don't have to keep moving the data around because now I have async >> things (data load) happening between screens. >> >> >> Thanks >> ___ >> Interest mailing list >> Interest@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest > > ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QML global variables?
Many thanks. What do you mean by "Note: If your data are js dictionary make sure to merge left or right the data before assignation." If I use "property var screenData: windowsUniqueId_.appData" then it should create a property binding, and merging should not be needed, correct? Sent: Tuesday, January 06, 2015 at 2:14 PM From: "Jérôme Godbout" To: "Jason H" Cc: "interest@qt-project.org" Subject: Re: [Interest] QML global variables? You can try to use a singleton, seem like what you need. Inside qmldir: singleton Settings 1.0 Settings.qml At the beginning of Settings.qml pragma Singleton // import goes here QObject { property var appData } Then you can use the Settings.appData Or you can use the cascading into scope. Each your screen should be able to reach the Windows id (make sure to never use it again) Main.qml Window { id: windowsUniqueId_ property var appData Screen1 {} Screen2 {} } Screen1,2,3.qml: Rectangle { property var screenData: windowsUniqueId_.appData } Note: If your data are js dictionary make sure to merge left or right the data before assignation. On Tue, Jan 6, 2015 at 2:02 PM, Jason H <jh...@gmx.com> wrote: What is the proper way to declare a dynamic global? Currently my app is set up with main.qml: Window { property var AppData; Screen1 { onEnter: { screen1.screenData = appData.screen1 }, onExit: { appData.screen1 = screen1.screenData }} Screen2 { onEnter: { screen2.screenData = appData.screen2 }, onExit: { appData.screen2 = screen2.screenData }} Screen3 { onEnter: { screen3.screenData = appData.screen3 }, onExit: { appData.screen3 = screen3.screenData }} } Screen1,2,3.qml: Rectangle { property var screenData; } I'd like to just have the screens and Window reference the same variable so I don't have to keep moving the data around because now I have async things (data load) happening between screens. Thanks ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QML global variables?
You can try to use a singleton, seem like what you need. Inside qmldir: *singleton Settings 1.0 Settings.qml* At the beginning of Settings.qml *pragma Singleton* *// import goes here* *QObject* *{* *property var appData* *}* Then you can use the *Settings.appData* Or you can use the cascading into scope. Each your screen should be able to reach the Windows id (make sure to never use it again) *Main.qml* *Window * *{ * * id: windowsUniqueId_* * property var appData* * Screen1 {}* * Screen2 {}* *}* *Screen1,2,3.qml:* *Rectangle* *{* * property var screenData: windowsUniqueId_.appData* *}* Note: If your data are js dictionary make sure to merge left or right the data before assignation. On Tue, Jan 6, 2015 at 2:02 PM, Jason H wrote: > What is the proper way to declare a dynamic global? > > Currently my app is set up with > main.qml: > Window { > property var AppData; > Screen1 { onEnter: { screen1.screenData = appData.screen1 }, onExit: { > appData.screen1 = screen1.screenData }} > Screen2 { onEnter: { screen2.screenData = appData.screen2 }, onExit: { > appData.screen2 = screen2.screenData }} > Screen3 { onEnter: { screen3.screenData = appData.screen3 }, onExit: { > appData.screen3 = screen3.screenData }} > } > > Screen1,2,3.qml: > Rectangle { > property var screenData; > } > > I'd like to just have the screens and Window reference the same variable > so I don't have to keep moving the data around because now I have async > things (data load) happening between screens. > > > Thanks > ___ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[Interest] QML global variables?
What is the proper way to declare a dynamic global? Currently my app is set up with main.qml: Window { property var AppData; Screen1 { onEnter: { screen1.screenData = appData.screen1 }, onExit: { appData.screen1 = screen1.screenData }} Screen2 { onEnter: { screen2.screenData = appData.screen2 }, onExit: { appData.screen2 = screen2.screenData }} Screen3 { onEnter: { screen3.screenData = appData.screen3 }, onExit: { appData.screen3 = screen3.screenData }} } Screen1,2,3.qml: Rectangle { property var screenData; } I'd like to just have the screens and Window reference the same variable so I don't have to keep moving the data around because now I have async things (data load) happening between screens. Thanks ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest