[Interest] Struggling with moveEvent()

Murphy, Sean smurphy at walbro.com
Tue Oct 2 15:15:41 CEST 2018


> 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?

I've come around to agree that I should just close it whenever focus leaves it,
which then means I don't need to worry about figuring out how to detect
when I need to move it.

Regarding your setMenu question, I did consider it, but I didn't think it would
work for my needs - although I could be wrong about that. Here's my requirements:
1. I need a widget that pops up when the user clicks on a button So this requirement
  *could* be handled by QPushButton::setMenu(), but I believe it's the subsequent 
  requirements that get me into trouble
2. I want the popup to have a "caption bubble" look to it as shown here 
  https://imagebin.ca/v/4Hi83WgTMrmp where the little triangle is lined up 
  with and touching the pushbutton that was pushed to trigger this menu being shown
3. I want the "menu" to allow me to put my own interactive widget in it, not just
  QAction-based menu items. For example, one pushbutton will allow the user to 
  select a color from a color picker. So clicking that pushbutton should pop up a "menu" 
  that looks like this https://imagebin.ca/v/4Hi9KpUg8Vk8 where there are no menu 
  items like you'd normally find on a QMenu, just the color picker that the user can interact
  with

Requirement 1 could obviously use a QMenu and QPushButton::setMenu(). I think I
might even be to satisfy #2 using something that inherits from QMenu and does
some additional painting to add the triangle feature where it needs to be. I don't 
know if I can satisfy #3 though by inheriting from QMenu? The only thing I can think 
of is when I want to add my custom child widget (like the color picker), that on those 
menus I don't add an QActions, instead adding a child widget? I haven't tried this route 
yet, so I don't know what I'd run into?

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com


More information about the Interest mailing list