[Interest] QListView with delegate: support drag outside of QApplication
Frank Rueter | OHUfx
frank at ohufx.com
Tue Jul 31 11:13:04 CEST 2018
Been trying to play with the view's dragMoveEvent to take over the
default drag event's mime data and create a custom QDrag instance with
it, but that crashes. I also tried just adding test to the event's mime
data, but that has no effect.
Maybe I do need to just re-implement the drag from scratch?
It feels like there should be a more elegant solution, right?!
On 30/07/18 3:24 PM, Frank Rueter | OHUfx wrote:
> 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
> Interest mailing list
> Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest