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);}");
    ObjectsAction = new QAction("Test menu", this);
    ObjectsButton = new QToolButton();
    ObjectsButton->setIcon(QIcon("F:/Izanagi Games/TWE/UI/ObjectBut_NotSelected.png"));

    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)?

  • Moderators

    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 ?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.