PDA

View Full Version : Enable sorting in QComboBox



kazek3018
13th February 2011, 22:31
Hello.

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.

wysota
13th February 2011, 23:07
Is the proxy a QSortFilterProxyModel?

kazek3018
13th February 2011, 23:32
Yes, it is.

wysota
13th February 2011, 23:57
And what happens if you call sort() on it?

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

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

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