I am newbie to Qt. I have to display a chunk of data in a QTableView
and filter it column wise. For this I have used QSortFilterProxyModel
, but as per requirement each column of the QTableView
should have a drop-down list which shows unique values in that column. On selectio开发者_StackOverflow社区n of any of these values in the drop-down, only the rows having that particular value in the column should be displayed in the QTableView
(Like you can do in Excel).
How would I implement this?
I had the same issue a week ago I found a tutorial explaining how to do it. see link below http://programmingexamples.net/wiki/Qt/Delegates/ComboBoxDelegate
Now my problem is how to retrieve the value of a specific combobox. I think it is such a complex things to do in C++ and Qt display a combobox into a tableView. For being a web developer at first I can tell that web language are better suited to do thoses kind of things.
But still some time performance matter and I tried to do it in C++ with Qt but it is not as easy as it seems to be in Web language.
This is very general question, and if I try to explain it all it will take pages, so it's better if you read the Qt model/view architecture documentation.
You can create your own class inherited from QTableView
to create your customized table view. You have to use delegates for drop down functions and all. so read the QItemDelegate
class documentation and documentation on subclassing delegates as well.
If you want to display it always and not just when editing, I would suggest setting a widget for the specific column like described in this thread: Qt - QTableView - Clickable button in table row
精彩评论