[Qt-interest] Using QStyleSheet to Restyle Checkable Menu Items

Jake Colman colman at ppllc.com
Fri Sep 17 20:54:02 CEST 2010


>>>>> "Jake" == Jake Colman <colman at ppllc.com> writes:

   Jake> It turns out, now that I have actually displayed a checkable
   Jake> QAction on a menu, that the checkable item already uses a
   Jake> checkbox.  All I really need to do is configure things so that
   Jake> the box turns red when checked.  Ideally, I'd also prefer if
   Jake> the checkbox had smaller dimensions.  Any easy way to
   Jake> accomplish one or both of these?

I tried specifying the following stylesheet:

QMenu::indicator:non-exclusive:checked { color: red; } 
QMenu::indicator:exclusive:checked { color: red; }

I called setStyleSheet on my QMenu-derived class and passed in the above
string.  The checkable menu item now displays as a larger than normal
odd-looking box and, when clicked, it display an odd-looking black dot
inside the odd-looking box.

What have I missed here?

TIA!

...Jake


-- 
Jake Colman | Director, Software Development
Principia Partners LLC
101 West Elm Street | Conshohocken | PA 19428 | +1 (610) 755 9770
t: +1 (610) 755 9786 | c: +1 (610) 348 2788 | f: +1 (201) 221 8929
e: colman at ppllc.com | w: www.principiapartners.com
Credit technology innovation awards winner 2008 and 2009




More information about the Qt-interest-old mailing list