[PyQt] Drag & Drop with QTreeWidget

NARCISO, Rui RUI.NARCISO at airbus.com
Mon Dec 14 09:12:01 GMT 2009


It worked nicely up to the sorting part.

And if th euser sorts the data himself, then eveything is ok.

It's just when I try to implement default sorting that that fails.

Maybe I can pick up on a signal telling that sorting is in progress to override this behaviour in the rowsInserted function...

-----Message d'origine-----
De : Baz Walter [mailto:bazwal at ftml.net]
Envoyé : vendredi 11 décembre 2009 21:46
À : NARCISO, Rui
Cc : PyQt (E-mail)
Objet : Re: [PyQt] Drag & Drop with QTreeWidget


NARCISO, Rui wrote:
> Hi again
> 
> Your approach worked nicely but when I tried to enable sorting using:
> 
>          self.setSortingEnabled(True)
>          self.sortByColumn(0, QtCore.Qt.AscendingOrder)
> I get a segmentation fault.
> 
> If i disable the sortByColumn then it works.
> 
> How then to set the sorting using column 0 by default ?

actually, i now think my approach was too crude. the trouble with using 
rowsInserted is that it is called every time items are added or moved 
(or sorted).

what is really needed is a way to add special handling only for dropped 
items. unfortunately, there does not appear to be an obvious way to 
detect what items were dropped and where. so i think the only reliable 
way to get the behaviour you want is to reimplement qtreewidget's drop 
event handling (which is probably doable, but not easy).


This mail has originated outside your organization, either from an external partner or the Global Internet.
Keep this in mind if you answer this message.



The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.




More information about the PyQt mailing list