[PySide] problems with drag event in QListView with delegate in edit mode
Frank Rueter | OHUfx
frank at ohufx.com
Wed Aug 8 10:56:11 CEST 2018
I have QListView with an item delegate that is animated when the mouse
overs over it.
This is done via a delegate using a custom widget and popping the index
under the cursor into edit mode like so:
|def mouseMoveEvent(self, event): if index.isValid(): # start playing
playing under cursor self.edit(index) |
This works fine and I have a mechanism for closing the editor as well to
ensure only one item is ever playing as the mouse moves around the list
The issue now is that the custom drag&drop behaviour has suffered - but
only under windows and linux, it works fine on OSX.
In order to close the editor when the left mouse button is clicked I do
this in the QListView’s mousePressEvent():
|def mousePressEvent(self, event): if self.currentEditor: try: # clean up
open editor self.currentEditor.setFocusPolicy(QtCore.Qt.NoFocus)
self.commitData(self.currentEditor) self.setFocus() except RuntimeError:
# no current editor. click happened outside the thumbnails pass
super(ElementView, self).mousePressEvent(event) |
On OSX, this enables the QListView’s default drag&drop behaviour when I
click and drag one of the items.
On windows however I need to click twice and only on the second click
the drag event kicks in.
If I comment out the above self.edit(index), drag&drop works fine on all
platforms, but of course I’m not getting the animation.
I also tried using persistent editors to no avail (same result).
Does anybody have an idea what I need to do to make this work ion
windows as well?
I have been trying to figure this out for hours now and am getting nowhere.
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...
More information about the PySide