[PyQt] stopping tool button from staying depressed in D
Hans-Peter Jansen
hpj at urpla.net
Tue Sep 21 19:51:19 BST 2010
On Tuesday 21 September 2010, 18:30:33 danny wrote:
> Howdy,
>
> I'm in progress dragging icons off a toolbar. I currently create
> QToolButtons and use addWidget to add them to the toolbar. I am starting
> the drag by connecting to the pressed even of the QToolButton, e.g.
>
> button.pressed.connect(self.startDrag)
>
> Life is good. I have a small visual artifact that the button now stays
> pressed for all eternity. The best I have been able to do is to modify
> startDrag
>
> def startDrag(self):
> button.setDown(False)
> ...
>
> I have also tried starting the drag by overloading mouseMoveEvent. The
> button still stays pressed, and I need to do a self.setDown(False).
Danny, show us your overload, or even better a minimum runnable example.
You should also catch the mousePressEvent and prevent the press from being
delivered to the Qt event machinery, e.g. call event.ignore() on left
clicks.
Consequently, you should start the drag yourself in the mouseMoveEvent, as
the above might prevent button.pressed.connect() from working correctly..
Pete
More information about the PyQt
mailing list