PDA

View Full Version : applying styles to single QAction



htroyo
23rd April 2011, 01:57
hello, i'm creating an application with QMenu's, and i want to apply a stylesheet to a single QAction item, but QAction has not setStyleSheet method, how can i apply a custom style to a SINGLE QAction?

htroyo
26th April 2011, 01:56
does anybody know?

ChrisW67
26th April 2011, 02:58
A QAction has no visible representation, i.e. it is not a QWidget, so applying a style to it directly makes little sense. You would have to address this through a stylesheet on the QToolbar or QMenu

What effect are you trying to achieve for a particular entry on a menu?

htroyo
27th April 2011, 05:04
set a different background for a single QAction, something to "highlight" the QAction, something to emphasize it

htroyo
28th April 2011, 04:32
or is it posible to assign an id to QActio as in html? maybe setting the style for QMenu:item#singleitemid works, but i don't how to set the object's id

ChrisW67
28th April 2011, 05:10
You set the QAction's objectName() with setObjectName() (see QObject). I'm not sure the QAction is the object that the :item subcontrol refers to though.

MarekR22
28th April 2011, 08:16
or is it posible to assign an id to QActio as in html? maybe setting the style for QMenu:item#singleitemid works, but i don't how to set the object's id
Yep it is. Try: QAction::data.

htroyo
1st May 2011, 01:17
unfortunately QAction::setObjectName() didn't work for setting the style for the single QAction, but thanks anyway...
and why data()? i read documentation but i don't understant the QVariant class and how can i use it, could you explain me please?
or another alternative?