multipleModels/oneView
Qt has provided a Quick way to display data in a grid or tree using model/view architecture, but they assumed that one view can display one model using one datasource like SQL table, I need away to display multiple Models at the same time in one tableView .
the problem come from the need of doing many DML operations visually by the end user.
13 replies
You shall not create a view, you shall create a model. And creating models is not so dificult, I did that many times now.
You just have to decide, whether you create your own model or a proxy model. If you don’t need the single base models stand alone, creating one model is easier than creating a proxy model.
More about creating xutsom model can be found here [doc.qt.nokia.com]
Afaik there are no model inside Qt where you can combine different sources into one model. Perhaps there is some thirt party solution, but that I don’t know.
It does not make any sense that a (Table)View works on more than one model. From both a programmers and a users view this is not intuitive and error prone.
As Gerolf already suggested, it’s the best to make either your own ItemViewModel or try to combine the existing ones (you can add more than one table to QSqlRelationalTableModel).
but this is the maximum number of tables you can use at the same time ,you can use two tables.
Actually it is not true, the number of the tables is not limited. You have a master table which has several foreign keys to other tables and you can set all the relations to those tables. If you want to do a read/write model it is recommended to use the QSqlRelationalDelegate.
You must log in to post a reply. Not a member yet? Register here!






