I'm half a step closer I think:
I'm using the QStyledItemDelegate.createEditor method to assign my
custom widget to the delegate as an editor:
class ToolButtonDelegate( QStyledItemDelegate ):
'''Delegate for ToolView. Might have to use widget instead to get
mouse over effects'''
def __init__( self, parent=None ):
super( ToolButtonDelegate, self).__init__( parent )
self.parent = parent
def createEditor( self, parent, option, index ):
if not index.isValid():
return False
btn = FancyButton( index.data( Qt.UserRole ), parent=parent )
return btn
This draws the "FancyButton" widget when the item is clicked, or
whatever else the View's editTriggers are set to.
Unfortunately there is no "mouseOver" edit trigger which could have been
a feasible workaround.
I am just experimenting with connecting the QAbstractView.entered signal
to the QAbstractView.edit slot but with very limited success. I get the
editor on mouse over for the first item, but it stays open and I get
"edit: editing failed" on all subsequent enter event.
There is no "left" signal to close the editor again when the mouse
cursor leaves the respective item, so I'm not sure if it's possible to
use this approach.
On 2/07/12 5:20 PM, Frank Rueter | OHUfx wrote:
Does anybody have an idea how to do this?
This seems to be turning into a show stopper for me.
I found this thread but since it's C++ I have a hard time deciphering it:
http://www.qtcentre.org/threads/8660-Drawing-a-widget-in-QItemDelegate-s-paint-method
I don't need to edit the item data, just need to represent it with a
custom widget (showing various buttons inside the widget on mouse
over) and make it drag&dropable.
I've attached a screen grab of what my working custom widget looks
like (with and without mouse over). I hope it comes through ok.
I *just* need to be able to use this as a delegate somehow.
Cheers,
frank
On 25/06/12 3:47 PM, Frank Rueter | OHUfx wrote:
Hi all,
I'm just re-writing part of my existing code to use the mode/view
approach.
I already have a complex custom widget which is a large button that can
be dragged and dropped, and that shows "sub buttons" on mouse over (i.e.
smaller rectangles are displayed in the corners on mouse over which act
as buttons in their own right).
The whole widget works exactly like I want it to, but now I'm wondering
if it's possible to create a QStyledItemdelegate for the new model/view
approach to do the same thing. It will need the same event handling as
my custom widget, such as enterEvent, leaveEvent, mouseReleaseEvent,
mousePressEvent, mouseReleaseEvent and mouseMoveEvent.
Is this possible with a delegate? Or can it be achieved in other ways?
Any pointers would be much appreciated.
Cheers,
frank
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside