Split data to a groups in QTableView
-
Hi!
In database i have a data which are belongs to different groups. And i want display them as in a image below:
!http://s8.postimage.org/5hq66i62t/img.png(table)!Rows are sorted in groups. I have few suggestions about how to realise it:
- Use TreeView
- Some list or tree with tableview in items
- TableView with setSpan().
How it should be done in right way?
Thanks for advance. -
Here are two more alternatives:
4. Use a more advanced data grid, like "qicsTable":http://www.ics.com/products/qt/qicstable/ or "QTitanDataGrid":http://www.devmachines.com/qtitandatagrid-overview.html
5. Use QML, which supports grouping (but as of yet, no tables).There are many approaches, and I would not call the one better than the other for all cases. I'd probably avoid option 2 though, that looks like it could get messy rather soon.
If you are willing to shell out a bit of cash for a more powerful component, then that can be worth doing. Otherwise, I think going for a tree instead would be my first choice. You can style the root items to look like group headers easily. Qxt has a "delegate":http://libqxt.bitbucket.org/doc/0.6/qxtitemdelegate.html that can help you do this, but it is not that hard to do yourself either.
-
Thank you Andre!
QTitanDataGrid is a very good component but it's little bit expensive for my goals.
I think Tree is a good choice. Is QTreeView has an option which makes all items expanded? -
Yes, it does. There are several expansion related slots available. Try the documentation...