Unsolved Settings: how to save the status of multiple switch in a page reused many time
-
you can do like this
Component.onCompleted: console.log( swSE.values[0] ) Settings { id: swSE property variant values : [false,false,true] ...
but cant do this swSE["esw0"]
-
Hi @gfxx , you can do like this
Here is a sample code:-
Settings.qml
Rectangle { id: root anchors.fill: parent color: "grey" property bool a0: false property bool a1: false property bool a2: false property bool a3: false property bool a4: false property bool a5: true property bool a6: true property bool a7: true property bool a8: true property bool a9: true }
main.qml
Settings { id: dummySettings } Component.onCompleted: { for(var i=0;i < 10;i++) { console.log(dummySettings["a" + i]) } }
-
@Shrinidhi-Upadhyaya said in Settings: how to save the status of multiple switch in a page reused many time:
Rectangle
we are talking about Settings QML Type
+sorry but your code does not make sense i belive.. , you can not iterate like that. What you can do in your example is :for (var i in dummySettings){ console.log(i) }
...
-
Hi @LeLev , actually you guys were discussing about how you can access a variable for example like: esw0,esw1 etc and you have replied that you cant do this swSE["esw0"], but actually you can do it right, the code which i have written is just a sample code, you can replace the rectangle with Settings and inside that create 10variables like esw0,esw1 etc after you can access that in main.qml like the way i have done.
According to you, we can access variable only by this way
dummySettings.a0,dummySettings.a1
But we can access the variable by the way i have done.
If you copy paste my code, you will be able to see that,you will get the values printed in the console that means you are able to access the variable.
-
@Shrinidhi-Upadhyaya said in Settings: how to save the status of multiple switch in a page reused many time:
actually you can do it right
yes, in fact we can, i didn't knew that
@Shrinidhi-Upadhyaya said in Settings: how to save the status of multiple switch in a page reused many time:
actually you guys were discussing about how you can access a variable for example like: esw0,esw1
the original topic is "how to save Ui state"
-
@all
as I can understand ... is not possible "reuse" Settings because is only a table on Sqlite db. But these notice is only my suspicious, not other.
If is right, every time the system make a query on that table (only one) these is not so flexible .... I think is better to use a db instead Settings. In these way I can insert my query create(if not exist) - insert - select - update on myPageComponent and with the use of property string myNewTable I can set outside from myPageComponent, for example in my mainPage or in my nestedMainPage, a new name of data table, so if i create for example 1000 new nested page, I have only the problem of set new table name, and I can make these with a for cicle for example .... better than 1000 of other things.Any how if someone have notice that these is possible using Settings .... please I need to know these.
regards.
-
@JonB yes these work ... these is a news for my .... sorry. I'm a little bit confusing about QSettings work.
Any how in witch way these can be reused? Only make a new
Setting { id: newSetting1; }
I think ..... and outside of NestedPage .... so I think I have to run iterate outside of nestedPage and the use per connect property has checked the setting .... a long story how can I see .. .. but it could be that I didn't understand all these things.
-
@Shrinidhi-Upadhyaya We actually discuss settings iterated and reuse the page with the settings inside it ... If I understand correctly, this is not possible.
regards
-
@Shrinidhi-Upadhyaya yes your code sample work in my app too .... but for use it I must:
*declare 100 property (if I have only 100 of these)
*on top of nested page iterate trought Setting file .... than connect the result on bottom nested pageI'm really new in qml. But as I understand I have to declare property bool axx for every single variable and the reuse of the page becomes boring to do :(
I'm in wrong?
if they are true ... it is better to use the old queries and a specific sqlite database for custom setting operations.
I appreciate any reply about.
regards
-
Hi @gfxx , iam sorry for understanding your question in a wrong way, i had thought that Settings is a different page.Okay but still if you want to use properties inside Settings type, you can do it in the way i have told.
I did not get your point "Settings Iterated", can you explain me a bit, so that i can help your or at least it can be helpful to me also.
And what do you mean by "100+ 100 declaration of property" ? did not get it actually! -
@Shrinidhi-Upadhyaya said in Settings: how to save the status of multiple switch in a page reused many time:
i had thought that Settings is a different page
I have main + some top nested page + some bottom nested page inside some one of the top nested. The most part is a reused page. So I need to save state of all switch control .... Is really a good ideas to use setting ? As I understand is not good. But I repeat I'm really new in qml.
100 + 100 is my error . ++sorry. I correct the post.