Triggering common actions for a data model from a view
-
I have read the documentation for the topic “Model/view programming” several times.
The data model should support also the following actions at least.- Reloading of needed data
- Storing data in a selected format
I have got understanding difficulties to trigger such actions directly by a programming interface which is supported by a class like “QTreeView”.
- May views call member functions from their models directly?
- Do models need to connect to any signals (or events) for the desired data processing?
I wonder why it seems to be harder than expected to find existing small Qt examples for this use case.
-
Hi, I wrote a library to serialise models in binary, xml, csv and json. You can find it here referred as "Model Serialisation". it's not fully documented (hence the dev branch) but you can find an example usage here
Don't know if the questions are related to the above but I'll answer
May views call member functions from their models directly?
They may and they do
Do models need to connect to any signals (or events) for the desired data processing?
A bit to generic of a question. depends on the data processing
-
May views call member functions from their models directly?
They may and they doThanks for your quick answer.
It seems that I have overlooked the useful function “QAbstractItemView::model()”.
-
-
@elfring
Well to change the internal structure of cppcheck to use models in the
intended way would be a benefit but to change GUI to QML would not
in my opinion not bring anything worthwhile besides huge amount of new code to let
QML access the data. However, it would ensure a very good separation
between data and presentation as there is no shortcuts
interfacing QML with c++ backbone models.
However, cppcheck needs neither animation or hardware accelerated drawing so
its hard to see what the gain would be. ( compared to the extra work of using QML) -
hi
-
Will the support change for UI and QML file formats over time?
Well QWidgets are very stable and its very unlikely that UI format will radically change.
QML is more of a work in progress so it could happen that very old QML file would require some
minor changes to load in brand new Qt but given the history of avoiding breaking
even binary comparability, its not likely to be a real world issue. -
Would you like to help any more with the separation of data structures for models and views?
If you mean outside of answering question here in forum, then no thank you. :)
-
-
If you mean outside of answering question here in forum, then no thank you. :)
I am curious then if you would like to clarify related development topics.
- Do you know any higher level tools which can display structural differences between standard item models in a clear way?
- Have you got any experiences with “diff views” in this software area?