[PyQt] QTreeView DragDropMode (Copy vs. Move)

hosscomp ronnie.a.shoemaker at lmco.com
Tue Apr 24 18:30:03 BST 2012


No problem, Bart. Thanks for replying. I think I am on the right track (a
right track) now.  There seems to be many different ways to do what I am
trying to accomplish, but I haven't gotten the hang of quickly figuring out
the documentation and I am running out of time on this project. I think it
would have been quicker for me to do in HTML5, but we are stuck with IE7 on
these restricted machines. The one last thing I would like to do is have
this method remove the source row: 
-------------------------------------
   def dropMimeData(self, mimedata, action, row, column, parentIndex):
       if action == Qt.IgnoreAction:
           return True

       dragNode = mimedata.instance()
       print("mimedata : ", dir(mimedata))< span
style='font-size:10.0pt;font-family:"Courier New"'>
       print("type = ", mimedata.MIME_TYPE)
       parentNode = self.nodeFromIndex(parentIndex)

       # make a copy of the node being moved
       newNode = deepcopy(dragNode)
       newNode.setParent(parentNode)
       self.insertRow(len(parentNode)-1, parentIndex)
       self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
parentIndex, parentIndex) 
       if (mimedata.hasFormat('compass/x-ets-qt4-instance')):
           self.removeRow(row, parentIndex)

       return True
-------------------------------------------------------
The arguments(row, parentindex) here are obviously wrong, so I probably need
to override the drag event and change it to a move or something like that.



--
View this message in context: http://python.6.n6.nabble.com/QTreeView-DragDropMode-tp4680293p4914167.html
Sent from the PyQt mailing list archive at Nabble.com.


More information about the PyQt mailing list