[Interest] Struggling with moveEvent()

Tony Rietwyk tony at rightsoft.com.au
Tue Oct 2 02:47:17 CEST 2018

Hi Sean,

Widgets are normally positioned relative to their owner - the exception 
is popup menus, which are screen absolute.  I would expect a popup menu 
to automatically close when the title bar is clicked.  How have you 
implemented your captionPopupMenu?  Does it capture the mouse when it is 
visible?  It should close if the mouse is clicked anywhere outside its 
borders.  Since you've got a QPushButton, did you consider using its 
setMenu to achieve a similar result?

Regards, Tony

On 2/10/2018 4:11 AM, Murphy, Sean wrote:
> My basic question is how do child widgets get moved or repainted when some ancestor of theirs moves?
> Here's the more detailed issue, first the widget hierarchy:
> QMainWindow
>     CustomerHeaderTable (inherits from QTableWidget)
>         CustomTableHeader (inherits from QHeaderView, allows you to put widgets in the header sections)
>             dataConfigWidget (inherits from QWidget)
>                 QPushButton
>                 captionPopupMenu (inherits from QWidget, starts out hidden)
> What I'm trying to accomplish is when the user presses the QPushButton, that a custom popup menu (the captionPopupMenu) appears aligned to the pushbutton. Right now I've got the initial alignment working just fine. The issue is when the popup is visible, if the user then grabs the application title bar and moves the entire main window around, the popup isn't moving with the application. So I figured I just need to update the captionPopupMenu's position in dataConfigWidget's moveEvent() to keep it positioned correctly. But it appears when the main window moves around, the dataConfigWidget's moveEvent() is never called - I put some qDebug() statements in there to verify. Same goes for paintEvent() - my child widgets aren't getting called when the ancestors move.
> So I'm not sure what I need to trigger off from to detect when I need to reposition the menu. I feel like I'm missing something really obvious, but not seeing it on a Monday apparently.
> Sean
> This message has been scanned for malware by Forcepoint. www.forcepoint.com
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

More information about the Interest mailing list