[Qt-interest] QDockwidget popup menu unexpected show

Christophe THOMAS oxygen77 at free.fr
Thu Dec 18 19:20:58 CET 2008


HEllo,

I've looked a bit more in the source (I'm enhancing an existing app). 
You were right, it is using mouseReleaseEvent which under certain 
circumstances emits a signal to another class called mouseClicked (this 
is what was confusing me:)).

The problems is not solved when I add accept() calls. The mouse handler 
is showing a custom popup menu when a right click is done (using 
menuPopupBtRight->exec(QCursor::pos());). This popup menu has severel 
actions, some are just some simple code others are using dialobgs. It 
looks like that actions that uses dialog are messing things. One of the 
action is deleting some objects, so I have confirmation box that is 
called, when I have the call to the msg box the dockwindow popup is 
shown, if I remove the call the dockxindow is not called anymore.

thx

Chris,

Tony Rietwyk a écrit :
> 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
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>   




More information about the Qt-interest-old mailing list