[PyQt] Drag status message

David Boddie david at boddie.org.uk
Wed Dec 3 01:09:41 GMT 2008


On Sun, 30 Nov 2008 15:12:34 -0500, Ron Longo wrote:

> I've implemented my own drag operation in a view class.  In my
> mousePressEvent() I setup for possible drag event (e.g. save the location
> of the mouse press).  In mouseMoveEvent() if a drag is started (mouse
> button pressed and mouse moved) I initiate a drag event.  In this method I
> create a QDrag object then call its exec_() method.

OK, sounds good so far.

> During the drag operation I repeatedly get calls to my dragMoveEvent().  In
> this method, I want to check the position of the mouse cursor and update
> the status bar to provide user feedback.  I do this by calling
> self.setStatusTip().

Have you tried calling self.statusBar().showMessage() instead?

> When I run my application and perform a drag, I see nothing until the drag
> is completed.  I then see the status bar updated with the text passed to
> the last call made to setStatusTip().

If the above suggestion works then I have an idea why self.setStatusTip()
does not; otherwise, some more investigation will be required. :-)

> The call to QDrag's exec_() method takes control of the drag operation
> until the drag is completed.  Once the drag is completed exec_() returns.
>  Is exec_() crating a separate event loop?  Is there any way to force the
> main event loop to update the GUI so that my status message will appear
> during the drag operation?

exec_() is creating an event loop, but events should still be delivered to
the window. It could just be that changing the status tip on its own isn't
enough to display a new message.

David



More information about the PyQt mailing list