[Solved] Dynamically set style.



  • Hi all,

    I'm trying to dynamically set application style in a following way:

        QApplication::setStyle(QStyleFactory::create(styleName));
        QApplication::setPalette(this->style()->standardPalette());
    

    where styleName can be one of QStyleFactory::keys();
    Every time above is executed look of the application changes but not correctly. To complete application must be restarted.

    Is there a way how to avoid restarting?

    Thanks,
    Tomas



  • OK, I found a solution.
    Two methods have to be called in reverse order.

        QStyle *style = QStyleFactory::create(styleName);
        QApplication::setPalette(style->standardPalette());
        QApplication::setStyle(style);
    

    And now it works as desired.

    Tomas


Log in to reply
 

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