[Interest] Struggling with moveEvent()
Adam Light
aclight at gmail.com
Tue Oct 2 21:28:54 CEST 2018
On Tue, Oct 2, 2018 at 6:16 AM Murphy, Sean <smurphy at walbro.com> wrote:
>
> 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
>
>
I'm not sure about #2, but I think you should be able to implement what you
want by creating a QMenu which has a single action. The action would need
to be a QWidgetAction, not a regular QAction. Your QWidgetAction would
provide a widget to do the actual color picking. We do this in our
application.
Here's a QToolButton that shows the currently selected color (we
reimplement paintEvent()) to do this:
[image: image.png]
And here's what it looks like when the user clicks on the tool button:
[image: image.png]
You can also insert the QWidgetAction into a regular contextual menu to get
something like this:
[image: image.png]
One note: in our experience, using QWidgetActions in the main menubar on
Macintosh doesn't always work correctly.
For what it's worth, the other tool buttons you see in the second image
work similarly, except the "+" button lets you pick a symbol and the "i"
button lets you pick a character.
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181002/e4149d7b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 2381 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181002/e4149d7b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 117500 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181002/e4149d7b/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 60683 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181002/e4149d7b/attachment-0002.png>
More information about the Interest
mailing list