Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[solved] Multiplie headers in QTableView by specific record data
I'm thinking of making an inventory application that could be continously extended later.
I want to store the part's data in SQL or SQLite, that's the easier part. As there are lots of different types of parts, I want to have a table, which describes the column names for every type, so I can have a smaller and more flexible database. Using QSqlRelationModel and a QTableView the basic functuality was up relatively quickly.
And here comes where I'm stucked. If I'm searching in the database, and there are let's say 10 items, which are from 3 different types, I have to identify the columns. One way would be to update the QTableView's headers if the index changes, but it's not too good. I'm thinking to have sections and this way multiplie headers.
I'm seaching for the most flexible and comfortable solution. I though of inserting multiplie QTableViews into a custom widget, but in this way I have to sort the search results, and then dinamically create as many (with an upper limit) models and QTableViews as I need and embedd them into a widget.
Is there an easier or better solution?
broadpeak last edited by
In the Advanced Qt Programming book there is a similar(?) solution in the "censusvisualizer" sample project. There the header of the tableview is a separate built class, which is upon a specific model. From "here":http://www.qtrac.eu/aqpbook.html you can download the source code of this book.
Well, thanks for the example, but maybe I wasn't clear enought. I thought something similar to @http://images.devshed.com/af/stories/ado reference/ch2img2.jpg@
(sorry for the link, but space wasn't recognized by the editor)
I want to have more tables from the same model based on a filter. I just wondering on which is the better solution. Have a query and make a lot of models and QTableViews or have a single model and filter that and subclass QTableView somehow or any other better idea is welcomed :)
broadpeak last edited by
I think the latter is the better: so, one model, and many filtered table.
Because if your dataset is changed, very complicated to modify the several models, much eaiser modify one model. Filter and delegate can help for your tableview.
Yeah, that's was my first thought. Set up a QStringList based on the search and then just create a few QTableViews through an iteration and insert them into a widget. Thanks!