Important: Please read the Qt Code of Conduct -

Set Background Colour of addMenu item

  • Hi, using the following code, I am unable to set the background colour for a menubar item.

    @QMenu *configure = menuBar->addMenu(tr("&Configure"));@

    I am able to set the colour for everything else simply by using qApp->setStyleSheet(...) but I have been unsuccessful in getting the background for the menu to change. I'm guessing that since &Configure is a string it needs to be done is a completely different way...

    Thanks for any help!

  • Eehm... what?

    Set your stylesheets using setStyleSheet to any QWidget, i.e.:
    MyWindow::MyWindow(QWidget* parent = 0)
    : QWidget(parent)
    setStyleSheet("QMenu { }"); // this will set up style for every item
    // this will set up style only for QMenu, which has set up
    // the object name to "objectName" using
    // QMenu->setObjectName(...);
    setStyleSheet("QMenu#objectName { ... }");

Log in to reply