Try adding a half pixel offset (for example: rect.translated(0.5,0.5) ):
QRectF rect(0,0,48,11); painter.setRenderHint(QPainter::Antialiasing,false); painter.drawRoundedRect( rect.translated(0.5,0.5), 2.0, 2.0 );
I believe this is because the coordinate system places an integer between two pixels.
If you draw using smoothing and use a pen with a width of 1 pixel, then a drawing with exact integer coordinates leads to the fact that instead, lines are built with a width of 2 pixels. Only with this 0.5-pixel offset will you get lines just 1 pixel wide.
QRectF rect(0,0,48,11); painter.setRenderHint(QPainter::Antialiasing,true); painter.setBrush(Qt::NoBrush); painter.setPen( Qt::white ); painter.drawRoundedRect( rect.translated(0.5,0.5), 2.0,2.0 );
source share