Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Dynamically set style.
QtWS25 Last Chance

[Solved] Dynamically set style.

Scheduled Pinned Locked Moved General and Desktop
qapplicationqstyleqpalette
2 Posts 1 Posters 1.3k Views
  • 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 Offline
    T Offline
    tomas.soltys
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      tomas.soltys
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved