[Qt-interest] How to set textcolor for actions in QMenu?

Bo Thorsen bo at fioniasoftware.dk
Mon May 9 13:16:13 CEST 2011


Den 09-05-2011 11:15, Konrad Rosenbaum skrev:
> On Monday 09 May 2011 08:21:00 Wilhelm wrote:
>> I suppose this is a very simple question, but how do I set the textcolor
>> of the actions in a QMenu to different colors: say the first show be
>> black (normal), the next red, etc.
>
> You can't. Unless you write your own custom QMenu class.

Or write your own QStyle subclass.

> Menus are highly platform dependent, so Qt does the adaptations of what to
> show and how - you just set the state (checkable, checked, enabled, etc.).
>
> Why would you want to have colored menu entries anyway? Usually there is a
> better way of doing this.

The only place I've seen a request like this before is for the color of 
pens in for example drawing applications. In this case, a much better 
solution is to set an icon with the color.

Please read Arnolds mail about this, and think twice before breaking the 
rule. This is hard because it's a *really* bad idea.

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list