[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QSortFilterProxyModel: confusing with lessThan
From:       Maurizio Berti <maurizio.berti () gmail ! com>
Date:       2019-07-30 10:27:13
Message-ID: CAPn+-XRnrOAtSSu=rY_FPjypo-pc1uo8oNoZUCq8_qncUtf0dg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Il giorno mar 30 lug 2019 alle ore 10:17 Gottfried Müller <
gottfried.mueller@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

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr">Il giorno mar 30 lug 2019 alle ore 10:17 Gottfried \
Müller &lt;<a href="mailto:gottfried.mueller@gmx.de">gottfried.mueller@gmx.de</a>&gt; \
ha scritto:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">in a simple test I want to sort the items in an \
ascending order using my <br> own proxy. I expected a comparision of \
&quot;itemLeft.text() &lt; <br> itemRight.text()&quot;. But I had to code \
&quot;itemRight.text() &lt; <br> itemLeft.text()&quot; getting the ascending \
order.<br></blockquote><div><br></div><div>If you print self.proxy.sortOrder() \
you&#39;ll find out that you&#39;re currently using a descending order, which is why \
you&#39;ve to invert the comparison.</div><div>I suppose that&#39;s due to the \
default sortIndicatorOrder of the QTreeView header, which seems to be set to \
DescendingOrder if the indicator is not shown.</div><div>Just use \
self.sortByColumn(0, QtCore.Qt.AscendingOrder) and it will \
work.</div><div><br></div><div>Maurizio<br></div></div><br \
clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">È difficile \
avere una convinzione precisa quando si parla delle ragioni del cuore. - \
&quot;Sostiene Pereira&quot;, Antonio Tabucchi<br><a href="http://www.jidesk.net" \
target="_blank">http://www.jidesk.net</a></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic