[PySide] QListView with delegate: support drag outside of QApplication
Frank Rueter | OHUfx
frank at ohufx.com
Sun Jul 29 10:25:25 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.
Cheers,
frank
|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 =
QtGui.QStandardItemModel(list1)
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>* *
*<http://ohufx.com/compositing.html>*
<http://www.nukepedia.com/nubridge>
Your gateway to over 1,000 free tools... right inside of Nuke
<http://www.nukepedia.com/nubridge>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20180729/87ca5d67/attachment.html>
More information about the PySide
mailing list