PDA

View Full Version : [Style Sheet] QMenu::item:hover bug



spud
11th May 2007, 11:11
I have a problem with style sheets with Qt 4.2 on windows. The following code does not produce the wanted effect(see image).


app.setStyleSheet(
"QMenu::item:hover {"
" background: RGB(255,238,194);"
" border: 1px solid black;"
"}"
);

Does anybody know if this has been fixed for version 4.3? And also will 4.3 support "QMenu::item:checked"?

wysota
11th May 2007, 11:45
What is the desired effect? From what I see your stylesheet is fully respected... The only thing is that you need to set all the needed attributes if you want to use a custom background. And I don't think it's easily avoidable due to a way the XP style works. Using stylesheets causes custom rendering to be enabled which means the xp style is no longer used for your item. Trolltech is surely working on fixing that, but I wouldn't expect a full 'fix' in Qt 4.3. As for now I suggest setting the color and icon position yourself within the stylesheet.

spud
11th May 2007, 12:01
Well, the desired effect is to change the background of a menu item without losing the foreground. It works for the menu itself. Like for example "QMenu {background: RGB(255,255,255);}".
I would definitely characterize this as a bug(unwanted feature) and I just wanted to know if some one has tested it with Qt 4.3.

And by the way, I'm not trying to emulate the Office 2003 look, I just wanted to provide a minimal example. I am going for a comic book look and wanted to know to which extent I can expect to customze the menus.

wysota
11th May 2007, 14:11
Well, the desired effect is to change the background of a menu item without losing the foreground. It works for the menu itself. Like for example "QMenu {background: RGB(255,255,255);}".
I would definitely characterize this as a bug(unwanted feature) and I just wanted to know if some one has tested it with Qt 4.3.
Well, obviously changing the menu background is supported with your widget style whereas changing the item background is not. I'm not saying this is the intended behaviour, but it's certainly not what I'd call a bug. If something is not supported for objective reasons, it's not an error in implementation. For instance I wouldn't call the lack of sound support in Qt a bug :)

Does the stylesheet behave the same regardless of the application style you use?