Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Dynamically set style.

    General and Desktop
    qapplication qstyle qpalette
    1
    2
    1001
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tomas.soltys last edited by

      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

      1 Reply Last reply Reply Quote 0
      • T
        tomas.soltys last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post