Proper place to store the selected item of a model
-
I'm developing an application that uses global configuration profiles, which can be saved and loaded by the user. Almost all screens are affected by what is the currently selected configuration profile.
I'm in doubt about how to design this in Qt/QML. Should I implement this in the model, possibly by creating a "itemSelected" property and then some methods to read and edit it? Should I simply keep a reference in QML? What is considered a good practice in this case?
-
Hi,
Can you explain how you work with that global configuration profile ?
-
Sorry for the late reply. For some reason, this forum is not notifying me of new messages.
This global configuration is a state that gets transformed in an HTTP request to configure a third party system. Suppose that I have 20 parameters in this global configuration state. I might connect a slider to parameter 1, a checkbox to parameter 2, etc, until I have all of them available to my user through QML controls.
When the user finally clicks a "Send" button, I get the current state of my global configuration and mash it into an HTTP request.
My question is about good practices. I can see a lot of ways of doing this, but I want to know what's reasonable in Qt's land. Thanks a lot!
-
I was misunderstanding some basic concepts about Qt models, such as that they don't have a "selected row" concept.
What I need in the end was a model wrapper that can also hold an index. Qt offers this via the type DelegateModel.