2

Is it possible to style a QMenu:item to set a custom height?

I need it for a popup menu, by what I've been seeing it seems it's not possible but maybe someone knows for sure.

Ezee
  • 4,214
  • 1
  • 14
  • 29
tru7
  • 6,348
  • 5
  • 35
  • 59

1 Answers1

8

Have you tried to use QSS? This works fine for me:

QMenu::item {
    height: 42px;
    margin: 0px;
}

You can use pMenu->setStyleSheet("QMenu::item { height: 42px; margin: 0px; }");.

Note: Make sure you use :: and not : to reference the item.

Iuliu
  • 4,001
  • 19
  • 31
  • 1
    Yes I've tried that (setting programmatically) but with no effect althought other attributes -colors- are reflected well. I've tried under Windows and Android with the same non-result. I've also copy/pasted verbatim your code with no other attribs, (I know I make many typos :-) but with no result either. – tru7 Nov 11 '14 at 14:26