Unsolved Qmenu popup button style problem
-
I'm trying to style the button in the popup of a QMenu, but can't get to style it.
I'm programming in VS2015, and have tried menu different thing but can't get it to work.
The code I have tried in VS is:
QMenu *ObjectsMenu = new QMenu(); QPushButton *Button = new QPushButton(); ObjectsMenu->setStyleSheet("QMenu::item:hover { background-image:url(F:/Izanagi Games/TWE/UI/TextBox_NotSelected.png);} QMenu::QPushButton {background-color: rgb(255,0,0);}"); Button->setMenu(ObjectsMenu); ObjectsAction = new QAction("Test menu", this); ObjectsMenu->addAction(ObjectsAction); ObjectsButton = new QToolButton(); ObjectsButton->setMenu(ObjectsMenu); ObjectsButton->setPopupMode(QToolButton::InstantPopup); ObjectsButton->setIcon(QIcon("F:/Izanagi Games/TWE/UI/ObjectBut_NotSelected.png")); ui.toolBar->addWidget(ObjectsButton);
But i can't figure out hoe to style the actual button style, so does anyone know how to style the button (and i know the button is a QPushButton)?
-
@dkmiraidk
QMenu::QPushButton {background-color: rgb(255,0,0);}");
The stylesheet expects a sub-control rather than a control if you use
::
At the most you can try:
QMenu#pushButton { ... } //pushButton = objectname of QPushButton
Or since you already have a separate
QPushButton
object you can directly apply stylesheet to it ?