MultipleModels/oneView
-
Denis Kormalev, I think you are right, but I try to check if any one have other way , that will be annoying to make ModelList :) , and I will be obliged to make a custom QTableView .
-
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":http://doc.qt.nokia.com/4.7/model-view-programming.html
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).
-
[quote author="syrianzoro" date="1293645179"]but this is the maximum number of tables you can use at the same time ,you can use two tables.[/quote]
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.
-
I have same question. I have tableview and I want to display multiple tables from MYSQL on same view at a time. Is there any solution exist without creating custom model/view??
-
No Solutions..!!!
-
I agree with fcrochik. Create a view in SQL server with all of you related data, test it from the SQL sandbox and use it.
-
[quote author="nasit.bhavin" date="1372075788"]I have same question. I have tableview and I want to display multiple tables from MYSQL on same view at a time. Is there any solution exist without creating custom model/view??[/quote]
For the people who have multiple tables, are they the same set of columns and such? If so, why are they separate tables? And can you do an SQL query which presents all of your tables as a view? Because joining completely arbitrary tables in a single view would tend to be a non sensical thing to do. I am trying to understand the use case that people are looking for. I mean you can't sort a column on half bool's and half datestamps in a way that is particularly intuitive. Likewise, how do you define rowCount() in a model that has models with differing rowCounts. I can't see any general purpose way to do it that would make everybody happy. Merging models into a single model seems like a very application specific sort of task.
-
Hey Volker,
I don't understand why you said it's confusing and not usual! Let's say I have a table for customer and other one for address and the address table has some fields like 'zip_code', 'city','state' and so on. What should I do if I want to show a TableView with the complete information about customers? The QSqlRelationalTableModel just allow me to link a foreign key to a field on other table but in fact I want to link one foreign key to other table and show all fields of that table. Does someone have a solution? -
@plinioandrade said in MultipleModels/oneView:
Hey Volker,
I don't understand why you said it's confusing and not usual! Let's say I have a table for customer and other one for address and the address table has some fields like 'zip_code', 'city','state' and so on. What should I do if I want to show a TableView with the complete information about customers? The QSqlRelationalTableModel just allow me to link a foreign key to a field on other table but in fact I want to link one foreign key to other table and show all fields of that table. Does someone have a solution?Any solution?