title: change application palette run-time, without restarting the application
body: <p>I am successfully using a dark theme for &quot;fusion&quot; style for Qt5 application. I would like to add the feature to switch the theme. If the user is required to restart the application there is not problem with this, the palette is correctly initialized at application start-up. But I would like to be able to do this run-time, without restarting. Most of widgets support this possibility but some other (e.g. <code>QComboBox</code>, <code>QSpinBox</code>, <code>QTreeView</code>) don't.  This can be proved by the following snippet - just press the button 'Reset style' and you can see how some parts of widgets change correctly but other parts don't. I am using the latest Qt 5.10 on Windows 10. This seems to me as Qt bug but is there any workaround or hack?</p>
  <p>This is my <code>main.cpp</code>:</p>
  <pre><code>#include &quot;widget.h&quot;
  #include &lt;QApplication&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
  
      // apply the dark color scheme
      qApp-&gt;setStyle(&quot;fusion&quot;);
      QPalette darkPalette;
      darkPalette.setColor(QPalette::Window,QColor(53,53,53));
      darkPalette.setColor(QPalette::WindowText,Qt::white);
      darkPalette.setColor(QPalette::Disabled,QPalette::WindowText,QColor(127,127,127));
      darkPalette.setColor(QPalette::Base,QColor(42,42,42));
      darkPalette.setColor(QPalette::AlternateBase,QColor(66,66,66));
      darkPalette.setColor(QPalette::ToolTipBase,Qt::white);
      darkPalette.setColor(QPalette::ToolTipText,Qt::white);
      darkPalette.setColor(QPalette::Text,Qt::white);
      darkPalette.setColor(QPalette::Disabled,QPalette::Text,QColor(127,127,127));
      darkPalette.setColor(QPalette::Dark,QColor(35,35,35));
      darkPalette.setColor(QPalette::Shadow,QColor(20,20,20));
      darkPalette.setColor(QPalette::Button,QColor(53,53,53));
      darkPalette.setColor(QPalette::ButtonText,Qt::white);
      darkPalette.setColor(QPalette::Disabled,QPalette::ButtonText,QColor(127,127,127));
      darkPalette.setColor(QPalette::BrightText,Qt::red);
      darkPalette.setColor(QPalette::Link,QColor(42,130,218));
      darkPalette.setColor(QPalette::Highlight,QColor(42,130,218));
      darkPalette.setColor(QPalette::Disabled,QPalette::Highlight,QColor(80,80,80));
      darkPalette.setColor(QPalette::HighlightedText,Qt::white);
      darkPalette.setColor(QPalette::Disabled,QPalette::HighlightedText,QColor(127,127,127));
      qApp-&gt;setPalette(darkPalette);
  
      Widget w;
      w.show();
  
      return a.exec();
  }
  </code></pre>
  <p>This is <code>widget.h</code>:</p>
  <pre><code>#pragma once
  
  #include &lt;QWidget&gt;
  
  class Widget : public QWidget
  {
      Q_OBJECT
  
  public:
      explicit Widget(QWidget *parent = 0);
  
  };
  </code></pre>
  <p>and <code>widget.cpp</code>:</p>
  <pre><code>#include &quot;widget.h&quot;
  
  #include &lt;QVBoxLayout&gt;
  #include &lt;QComboBox&gt;
  #include &lt;QSpinBox&gt;
  #include &lt;QTreeWidget&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QApplication&gt;
  #include &lt;QStyleFactory&gt;
  
  Widget::Widget(QWidget *parent) :
      QWidget(parent)
  {
      auto layout = new QVBoxLayout(this);
      auto comboBox = new QComboBox();
      auto spinBox = new QSpinBox();
      auto listWidget = new QTreeWidget();
      listWidget-&gt;setHeaderLabels(QStringList() &lt;&lt; &quot;Column1&quot; &lt;&lt; &quot;Column2&quot;);
      auto button = new QPushButton(&quot;Reset style&quot;);
  
      // reset the palette to the default 'light' color scheme
      connect(button, &amp;QPushButton::clicked, 
              [] { qApp-&gt;setPalette(QStyleFactory::create(&quot;fusion&quot;)-&gt;standardPalette()); });
  
      layout-&gt;addWidget(comboBox);
      layout-&gt;addWidget(spinBox);
      layout-&gt;addWidget(listWidget);
      layout-&gt;addWidget(button);
  }
  </code></pre>
  <p>This is the dark one:</p>
  <p><a href="https://i.stack.imgur.com/YPLlI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YPLlI.png" alt="enter image description here" /></a></p>
  <p>and this after resetting the style:</p>
  <p><a href="https://i.stack.imgur.com/Rdp08.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rdp08.png" alt="enter image description here" /></a></p>
  <p>UPDATE: This bug has been reported to Qt and already fixed. Well done, Qt team.</p>