View Full Version : Enable sorting in QComboBox

13th February 2011, 23:31

I have my own class derived from QAbstractTableModel. When I'm select a column in QTableView header font is going to be bold. I try to play with Qt::FontRole for headerData() function, but this is not avoid font to be bold. Any idea how to do it?

Main problem is how to enable sorting in QComboBox. I have proxy model (with source from that QTableModel) which make behaviour like QListView for QComboBox. For this proxy I overwrite lessThan() function, but QComboBox in function view() return pointer to QAbstractItemView which do not have setSortingEnabled() (QListView do not have to). How to use lessThan function to sorting this proxy model?

Many thanks.

14th February 2011, 00:07
Is the proxy a QSortFilterProxyModel?

14th February 2011, 00:32
Yes, it is.

14th February 2011, 00:57
And what happens if you call sort() on it?

14th February 2011, 07:20
Thanks it's working (I should got break).

How to avoid bold font in QTableView when an item is selected?

14th February 2011, 08:31
Render the header yourself.