title: How to draw control with QStyle and with specified QSS?
body: <p>I'm trying to draw a checkbox in <code>QStyledItemDelegate</code>. I want checkbox to be drawng not with native look, but with style that specified with <code>qApp-&gt;setStyleSheet()</code>. I don't know why, but when I draw control with <code>QStyle::drawPrimitive</code> - it doesn't pick up global qss.</p>
  
  <p>Are there any solutions, how to manually draw check box with application style?</p>
  
  <p>Following code and screenshot demonstrate my problem:</p>
  
  <p><img src="https://i.stack.imgur.com/Y8tAm.png" alt="CheckBox sample"></p>
  
  <p>First check box is draw with <code>QStyle::drawPrimitive</code>, second check box is widget.</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QWidget&gt;
  #include &lt;QStyle&gt;
  #include &lt;QPainter&gt;
  #include &lt;QStyleOptionButton&gt;
  #include &lt;QCheckBox&gt;
  
  class TestWindow
      : public QWidget
  {
      Q_OBJECT
  
  public:
      TestWindow() {}
      ~TestWindow() {}
  
      void paintEvent( QPaintEvent * event )
      {
          QPainter p( this );
  
          QStyleOptionButton opt;
          opt.state |= QStyle::State_On;
          opt.state |= QStyle::State_Enabled;
          opt.rect = QRect( 10, 10, 20, 20 );
  
          style()-&gt;drawPrimitive( QStyle::PE_IndicatorCheckBox, &amp;opt, &amp;p, this );
      }
  };
  
  int main( int argc, char *argv[] )
  {
      QApplication a( argc, argv );
  
      a.setStyleSheet( "QCheckBox::indicator{ border: 1px solid red; }" );
  
      TestWindow w;
      QCheckBox *cb = new QCheckBox( &amp;w );
      cb-&gt;move( 10, 30 );
  
      w.show();
  
      return a.exec();
  }
  
  #include "main.moc"
  </code></pre>
  
  <p>Note: it is possible to create invisible check box and use <code>QPixmap::grabWidget</code>, but this method is too heavy.</p>