title: Problem with Tristate QCheckBox not repainting itself when set programmatically
body: <p>When I have a QCheckBox with tristate set true, it does not repaint itself when transitioning from Qt:PartiallyChecked to setChecked(true) programatically.</p>
  <p>A minimal example built in QDesigner places a QCheckBox and QPushButton on the central widget of the default MainWindow.  The QCheckBox is default configured except tristate is checked.  In code, the ui checkBox is set to Qt::PartiallyChecked in the constructor, and an on_pushButton_clicked() function calls ui-&gt;checkBox-&gt;setChecked( true );</p>
  <p>Expected behavior: when pushButton is clicked, checkBox should change from partially checked to checked appearance.</p>
  <p>Observed behavior: checkBox appearance does not change until moused over.</p>
  <p>Note: it's even worse when the checkbox has been restyled to be used as a tri-state indicator and is not enabled for user input... the disabled checkbox doesn't repaint on mouseover then.</p>
  <p>I discovered this behavior in Ubuntu 18.04 default using the native 5.9.5 Qt libraries running in release mode, but it is also reproducible in 5.14.2 and many other library versions.</p>
  <p>The sample code below is 99% the default Qt Widgets application with modification as described above.</p>
  <p>The only workaround I have found so far is to repaint the QCheckBox widget anytime its state is changed... not great, but at least it works.</p>
  <p>mainwindow.cpp:</p>
  <pre><code>#include &quot;mainwindow.h&quot;
  #include &quot;ui_mainwindow.h&quot;
  
  MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
      , ui(new Ui::MainWindow)
  {   ui-&gt;setupUi(this);
      ui-&gt;checkBox-&gt;setCheckState( Qt::PartiallyChecked );
  }
  
  MainWindow::~MainWindow()
  { delete ui; }
  
  void MainWindow::on_pushButton_clicked()
  { ui-&gt;checkBox-&gt;setChecked( true ); 
    // Uncomment the repaint() for a kludgey fix
    // ui-&gt;checkBox-&gt;repaint();
  }
  </code></pre>
  <p>mainwindow.h:</p>
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  
  QT_BEGIN_NAMESPACE
  namespace Ui { class MainWindow; }
  QT_END_NAMESPACE
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      MainWindow(QWidget *parent = nullptr);
      ~MainWindow();
  
  public slots:
      void on_pushButton_clicked();
  
  private:
      Ui::MainWindow *ui;
  };
  #endif // MAINWINDOW_H
  </code></pre>
  <p>main.cpp:</p>
  <pre><code>#include &quot;mainwindow.h&quot;
  
  #include &lt;QApplication&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.show();
      return a.exec();
  }
  </code></pre>
  <p>mainwindow.ui:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;ui version=&quot;4.0&quot;&gt;
   &lt;class&gt;MainWindow&lt;/class&gt;
   &lt;widget class=&quot;QMainWindow&quot; name=&quot;MainWindow&quot;&gt;
    &lt;property name=&quot;geometry&quot;&gt;
     &lt;rect&gt;
      &lt;x&gt;0&lt;/x&gt;
      &lt;y&gt;0&lt;/y&gt;
      &lt;width&gt;173&lt;/width&gt;
      &lt;height&gt;98&lt;/height&gt;
     &lt;/rect&gt;
    &lt;/property&gt;
    &lt;property name=&quot;windowTitle&quot;&gt;
     &lt;string&gt;MainWindow&lt;/string&gt;
    &lt;/property&gt;
    &lt;widget class=&quot;QWidget&quot; name=&quot;centralwidget&quot;&gt;
     &lt;widget class=&quot;QCheckBox&quot; name=&quot;checkBox&quot;&gt;
      &lt;property name=&quot;geometry&quot;&gt;
       &lt;rect&gt;
        &lt;x&gt;40&lt;/x&gt;
        &lt;y&gt;10&lt;/y&gt;
        &lt;width&gt;92&lt;/width&gt;
        &lt;height&gt;23&lt;/height&gt;
       &lt;/rect&gt;
      &lt;/property&gt;
      &lt;property name=&quot;text&quot;&gt;
       &lt;string&gt;CheckBox&lt;/string&gt;
      &lt;/property&gt;
      &lt;property name=&quot;tristate&quot;&gt;
       &lt;bool&gt;true&lt;/bool&gt;
      &lt;/property&gt;
     &lt;/widget&gt;
     &lt;widget class=&quot;QPushButton&quot; name=&quot;pushButton&quot;&gt;
      &lt;property name=&quot;geometry&quot;&gt;
       &lt;rect&gt;
        &lt;x&gt;40&lt;/x&gt;
        &lt;y&gt;50&lt;/y&gt;
        &lt;width&gt;89&lt;/width&gt;
        &lt;height&gt;25&lt;/height&gt;
       &lt;/rect&gt;
      &lt;/property&gt;
      &lt;property name=&quot;text&quot;&gt;
       &lt;string&gt;PushButton&lt;/string&gt;
      &lt;/property&gt;
     &lt;/widget&gt;
    &lt;/widget&gt;
   &lt;/widget&gt;
   &lt;resources/&gt;
   &lt;connections/&gt;
  &lt;/ui&gt;
  </code></pre>
  <p>Tristate.pro:</p>
  <pre><code>QT       += core gui
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  CONFIG += c++11
  
  # The following define makes your compiler emit warnings if you use
  # any Qt feature that has been marked deprecated (the exact warnings
  # depend on your compiler). Please consult the documentation of the
  # deprecated API in order to know how to port your code away from it.
  DEFINES += QT_DEPRECATED_WARNINGS
  
  # You can also make your code fail to compile if it uses deprecated APIs.
  # In order to do so, uncomment the following line.
  # You can also select to disable deprecated APIs only up to a certain version of Qt.
  #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
  
  SOURCES += \
      main.cpp \
      mainwindow.cpp
  
  HEADERS += \
      mainwindow.h
  
  FORMS += \
      mainwindow.ui
  
  # Default rules for deployment.
  qnx: target.path = /tmp/$${TARGET}/bin
  else: unix:!android: target.path = /opt/$${TARGET}/bin
  !isEmpty(target.path): INSTALLS += target
  </code></pre>