[Qt-interest] QDockwidget popup menu unexpected show
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Wed Dec 17 03:31:33 CET 2008
Chris wrote:
> In addition to my desription, this only happen under windows not on
> linux, I'm using Qt 4.5 preview.
> > Hello all,
> >
> > I have an application that uses some QDockwidgets, a popup
> menu is shown
> > when I right-click on the top of one them and I can
> hide/show the docked
> > widgets. This fine for me.
> >
> > I also have in the QMainWindow an event handler that manages
> > mouseclicked events of the central widget:
> mouseClicked(QMouseEvent *)
> > signal of the central widget connected to a slot of QMainWindow.
> > In this slot, when right-click is pressed, I show a
> contextual menu using:
> > menuPopupBtRight->exec(QCursor::pos());
> >
> > menuPopupBtRight is a QMenu* which is composed of several
> actions. For
> > actions that just execute some simple code everything is
> going ok, for
> > others that needs to use a dialog (a custom class or a
> QMessageBox),
> > just at the end of the action QDockWidget popup menu is shown.
> >
> > it looks like the first right-clicked event is send to
> parent in some
> > cases and not in others.
> >
> > thx
> >
> > Chris
Hi Chris,
In both Qt and non-Qt Windows applications, the context menu appears when
the right mouse button is released - not when it is pressed. The same
applies for click events - they occur after the release. Even though you
named the signal 'mouseClicked', you have coded it as 'mousePressed'. Also -
don't forget to accept() the event, otherwise it will still go back to the
parent.
Hope that helps,
Tony Rietwyk
More information about the Qt-interest-old
mailing list