Important: Please read the Qt Code of Conduct -

Inheritance of styleSheet

  • I set a styleSheet for my Application. The styleSheet is always pretty fine available.
    But when I generate a QMenu, with a QWidget as parent, the QMenu do not inherits the styleSheet. All other control do that! Just the QMenu do it not. Why?

    , ui(new Ui::Toolbar)
    , menu(new QMenu(this))

    qDebug() << this->menu->styleSheet() ==> output is: ""

  • Ok, I think I know the reason. It may be because the menu is created before setupUI is called

  • Sorry, that was not the reason. So I still do not know it yet.

  • Lifetime Qt Champion


    Setting a stylesheet on your application will not call setStylesheet on each and every widget created. The styling will be applied, that's all.

Log in to reply