[Interest] QMenu styling

André Somers andre at familiesomers.nl
Tue Aug 7 10:09:06 CEST 2012


Hi,

I am trying to style a QMenu and add an additional, menu-specific icon 
to the left of the actual items in the menu, like in the mockup here: 
https://dl.dropbox.com/u/16442531/menumockup.png

I subclassed QMenu to overwrite its paintEvent to render the icon and 
the vertical line, which works fine. I though I'd create the space for 
these by using the padding CSS trick  like this:

setStyleSheet("padding-left: 44px;");

According the documentation, QMenu supports the box model, and thus 
should allow for using padding. However, if I do the above, I end up 
with this: https://dl.dropbox.com/u/16442531/menuscreenshot.png

Notice the excess space on the right of the menu items, and even inside 
the items on the right side. Adding an explicit padding-right: 0px; to 
the style sheet does nothing.

I am starting to wonder if QMenu actually correctly implements the box 
model at all. Can anyone give me some more insight into what is 
happening, and perhaps suggest an alternative way around this issue?

André






More information about the Interest mailing list