Qt Antialiasing with QPainter versus QStyleSheets
<p>Here are two <code>QWidget</code> painted black. The painting on left <code>QWidget</code> was performed using <code>QPainter</code> (overriding <code>::paintEvent(...)</code>). The right widget was "painted" using <code>QStyleSheet</code>.</p>

<p><a href="https://i.stack.imgur.com/gSrJv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gSrJv.jpg" alt="enter image description here"></a></p>

<p>This work was done in PyQt4 (<code>Python: 2.7.11+/Qt: 4.8.7/PyQt4: 4.11.4</code>). But you I have achieved the same result using PyQt5 and C++ Qt4/Qt5.</p>

<p>The code I used to paint the left <code>QWidget</code> is</p>

<pre><code>def paintEvent( self, pEvent ) :

    painter = QPainter( self )
    painter.setRenderHints( QPainter.HighQualityAntialiasing )

    painter.setPen( Qt.black )
    painter.setBrush( Qt.black )

    painter.drawRoundedRect( self.rect(), 10.0, 10.0 )

    painter.end()

    pEvent.accept()
</code></pre>

<p>The stylesheet used on the right widget is</p>

<pre><code>setStyleSheet( "border-radius: 10px; border: 1px solid black; background: black;" )
</code></pre>

<p>Why is there a difference between the two, especially the rounded part drawn by <code>QStyleSheet</code> far more smoother than the one done by <code>QPainter</code> despite using <code>QPainter.HighQualityAntialiasing</code> render hint? You could use just <code>QPainter.Antialiasing</code> or <code>QPainter.TextAntialiasing</code> and still the situation does not improve.</p>