Important: Please read the Qt Code of Conduct -

Qt - not all widgets refreshed after stylesheet change

  • Hi,
    I have style manager, so user can change stylesheet and palette at runtime. But after this operation, not all widgets are "restyled". New look is applied when widget is recreated. Same code called from main window constructor is working like expected. Is exists any global signal which notify all widgets that they should refresh palette and stylesheet?

    This code is called from modal dialog:
    @QFile file(":/qss/default.qss");;
    QString styleSheet = QLatin1String(file.readAll());
    QPalette p = qApp->palette();
    p.setColor(QPalette::Window, QColor(53,53,53));
    p.setColor(QPalette::Button, QColor(53,53,53));
    p.setColor(QPalette::Highlight, QColor(175,0,0));
    p.setColor(QPalette::ButtonText, QColor(255,255,255));
    p.setColor(QPalette::WindowText, QColor(255,255,255));

    Some widgets apply new palette and stylesheet automatically but some not (like MainMenu where text is still black but should be white). Should I enumerate all widgets and apply palette on each widget?

Log in to reply