1 Attachment(s)
ContextMenu Very unique GUI.
I want to know the secrets of the context menu, because it seems to have a lot of hidden things, that are not clearly shown. Some programs, have unique interfaces for rightclick context menus.
An example is the image attached, it has like a sunken area with a gray background, where they just put some information about something.
Another example is like some programs like DevC++ or MS Visual studio that have like large context menus with like icons on the left etc.
I was wondering if anyone has any example code of how I can "tap into" these features.
Re: ContextMenu Very unique GUI.
Do I have to make my own PaintEvent and design it myself or something? How would I go bout doing this?
Re: ContextMenu Very unique GUI.
I think you should take a close look to Qt sources...it should explain a lot.
A context menu is just a QMenu displayed in a particular way, so there must be a particular painting method somewhere...I'll have a look
Re: ContextMenu Very unique GUI.
Well I looked in QMenu and QPainter, but I still cannot tell how they get that gray area, and I'm wondering how I can code it.
Re: ContextMenu Very unique GUI.
QMenu can only contain menu items (QActions). That's the paradigm you have to live with when using QMenu. There is no way to create gray regions. However, you can create your own menu-like widget, and then draw it any way you want. That's probably what you want to do.
Re: ContextMenu Very unique GUI.
Sounds difficult, but how the hell did they do it?
Any ideas on how I should lay that class? What events to handle or what functions to use?
Re: ContextMenu Very unique GUI.
Look at the QMenu code. That should give you all the information you need on creating your own QMenu-like class.
Re: ContextMenu Very unique GUI.
You can place widgets in menus (and also place a gray one ;) )
Code:
label->setAlignment( Qt::AlignCenter );
a->setDefaultWidget( label );
Re: ContextMenu Very unique GUI.
That sounds promising... THANKS A LOT!!!
Re: ContextMenu Very unique GUI.
One question why do we ever use "tr()"... what good does that do? Not only that it usually gives me compiler errors. I just remove it, because I don't see any point in using it.
Re: ContextMenu Very unique GUI.
Quote:
Originally Posted by
VireX
One question why do we ever use "tr()"... what good does that do? Not only that it usually gives me compiler errors. I just remove it, because I don't see any point in using it.
Internationalization with Qt
Re: ContextMenu Very unique GUI.
Quote:
Originally Posted by
gri
I didn't realize there was QWidgetAction. That's new in Qt 4.2. Thanks for the info.
Re: ContextMenu Very unique GUI.
Its amazing, the only problem I had is, I could not change the background of a QLabel inside the QWidgetAction. I changed the QPalette::Window, but that didn't do the trick, then I tried a stylesheet, it worked fine in designer but once you add it to the ContextMenu it sets the background as the default gray for context menus.
Re: ContextMenu Very unique GUI.
Hmm, still can't figure out a way to customize colors of conext menu, I tried Stylesheet on both QMenu and QLabel, but no luck, it changes fine in QDesigner but not when inside a context menu. Is there anyway to color the backgrounds of the context/qlabel stuff? I even tried QPainter.
Re: ContextMenu Very unique GUI.
Please search the forum. The issue of changing the background of a QLabel has recently been brought up.