[Interest] QListView with delegate: support drag outside of QApplication

Frank Rueter | OHUfx frank at ohufx.com
Mon Jul 30 05:24:03 CEST 2018

Hi all,

I have an app that uses two QListViews with delegates.
The user can drag ad drop items from one view into the other to create 
something like a shopping list.
So far so good.
Now I need to enable the user to also drag an item out of the 
application entirely.
Is it possible to access the drag event data that the list view produces 
by default, so I don’t have to re-invent the wheel for the already 
functioning internal drag&drop?

Here is a simplified example that just needs support for dragging an 
item outside of the QApplication.

Any tips would be much appreciated.


|import sys from PySide import QtGui, QtCore app = 
QtGui.QApplication(sys.argv) class MyList(QtGui.QListView): def 
__init__(self, parent=None): super(MyList, self).__init__(parent) 
self.setDragEnabled(True) self.setAcceptDrops(True) list1 = MyList() 
list2 = MyList() model1 = QtGui.QStandardItemModel(list1) model2 = 
model2.setItemPrototype(QtGui.QStandardItem()) foods = [ 'Cookie dough', 
'Hummus', 'Spaghetti', 'Dal makhani', 'Chocolate whipped cream' ] for 
food in foods: item = QtGui.QStandardItem(food) model1.appendRow(item) 
list1.setModel(model1) list2.setModel(model2) w = QtGui.QSplitter() 
w.addWidget(list1) w.addWidget(list2) w.show() w.raise_() app.exec_() |


ohufxLogo 50x50 <http://www.ohufx.com> 	
	*vfx compositing <http://ohufx.com/compositing.html> | *workflow 
customisation and consulting <http://ohufx.com/customising.html>* *

Your gateway to over 1,000 free tools... right inside of Nuke 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180730/826667db/attachment.html>

More information about the Interest mailing list