[PyQt] QSortFilterProxyModel: confusing with lessThan

Maurizio Berti maurizio.berti at gmail.com
Tue Jul 30 11:27:13 BST 2019


Il giorno mar 30 lug 2019 alle ore 10:17 Gottfried Müller <
gottfried.mueller at gmx.de> ha scritto:

> in a simple test I want to sort the items in an ascending order using my
> own proxy. I expected a comparision of "itemLeft.text() <
> itemRight.text()". But I had to code "itemRight.text() <
> itemLeft.text()" getting the ascending order.
>

If you print self.proxy.sortOrder() you'll find out that you're currently
using a descending order, which is why you've to invert the comparison.
I suppose that's due to the default sortIndicatorOrder of the QTreeView
header, which seems to be set to DescendingOrder if the indicator is not
shown.
Just use self.sortByColumn(0, QtCore.Qt.AscendingOrder) and it will work.

Maurizio


-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190730/6bffa5ae/attachment-0001.html>


More information about the PyQt mailing list