[PyQt] Drag & Drop with QTreeWidget

NARCISO, Rui RUI.NARCISO at airbus.com
Tue Dec 1 10:20:18 GMT 2009


Hi all

I'm trying to implement Drag & Drop in my QTreeWidget based GUI but it is not clear to me how to proceed (after having read the Doc and googled it).

I have several question (tree = QTreeWidget())
 1) I have activated:
	tree.setSelectionMode(QAbstractView.ExtendedSelection)
    yet before I would just keep the mouse pressed and slide over the selection I wanted but now that is not possible. Is there a way to maintain such behaviour and force that the drag is only performed on a second click over the selection ?

 2) how do I force a certain QTreeWidgetItem NOT to accept drops ?

 3) I have a specific tree:
       RootItem
             |
             | ---  Campaign1
             |            |
             |            |---- Folder1
             |                      |
             |                      |------ Calc1            path1      (where path1= /home/ .... /Folder1/calcname1 
             |                      |------ Calc2            path2      (where path2= /home/ .... /Folder1/calcname2
             |
             | ---  Campaign2

       So what I would like would be to drag only items of name "calc*" to nodes of type "campaign" (ex: Campaign2) and when doing so create the sub-node "Folder1" if it does not exist within "campaign" and put the dragged items under "folder1" (and not "campaign" where they were dropped). How to do this ? Do I do this in a dropEvent? In a dropEventAction ?

Thank you all for your help, I know it's not easy to answer this sort of hypothetic questions.

Cheers
Rui

PS: Sorry about the disclaimer on the bottom

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