Mutual dependent model in Qt model view

How to use Qt’s Model-View framework to implement interdependent models? Specifically, how do you create a model that contains fields that refer to data in another model? I want the data changed/deleted in the first model to propagate to the subordinate fields in the second model.

For example, I have a model called BookListModel which contains a series of Books. I have a second model called ReaderTableModel, which contains a list of readers (names) and the books they are reading. I want these books to be able to reference the corresponding index of the BookListModel and propagate any changes to the corresponding in the ReaderTableModel Entry.

Does Qt have this mechanism? Can I store QPersistentModelIndex in another model?

It may be good to consider how relevant the data the model adapts to. If you allow the model to change the data source Update them, and update yourself when the data source changes, so you don’t have to worry about the interaction between BookListModel and ReaderTableModel.

The pattern is as follows: When BookListModel changes, it will update its containing books The data source of the data. Then, you will update the book data of the ReaderTableModel from the data source of each reader.

This mode follows Qt best practices and treats the models as data adapters instead of using them For data storage. http://qt-project.org/doc/note_revisions/13/174/view

How to use Qt’s Model-View framework to achieve interdependence Model? Specifically, how do you create a model that contains fields that refer to data in another model? I want the data changed/deleted in the first model to propagate to the subordinate fields in the second model.

For example, I have a model called BookListModel which contains a series of Books. I have a second model called ReaderTableModel, which contains a list of readers (names) and the books they are reading. I want these books to be able to reference the corresponding index of the BookListModel and propagate any changes to the corresponding in the ReaderTableModel Entry.

Does Qt have this mechanism? Can I store QPersistentModelIndex in another model?

It may be good to consider how the data the model adapts to are related. If the model is allowed to update them when the data source is changed, and update itself when the data source changes , You don’t have to worry about the interaction between BookListModel and ReaderTableModel.

The data source of the reader updates the book data of the ReaderTableModel.

This mode follows Qt best practices and treats models as data adapters instead of using them as data storage. http://qt-project. org/doc/note_revisions/13/174/view

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2309 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.