Since setting border radius using stylesheets has unwanted effects, you could make your widget borders round without it, and use paintEvent instead, here's how:
You could draw a rounded rect with a color same as the widget parent's background, this acts as if it's hiding those sharp corners, and make them look round.
One downside of this method is that it limits how round the corners can get, because if the painter draws a too rounded rect, it will mask the widget itself or cause sharp edges.
It is possible to slightly get around that by increasing the border size, to get more space, thus, making it possible to increase the border radius when using a painter without ruining the widget edges.
There is an upside for using this method. It prevents the widget background from poking out the border.
Here's an example of subclass derived from QPushButton with a custom paintEvent:
class button : public QPushButton
{
Q_OBJECT
public:
button (QWidget *parent = nullptr) : QPushButton(parent) {}
protected:
void paintEvent(QPaintEvent *event) override
{
QPushButton::paintEvent(event);
QRectF r = rect();
r.adjust(-1,-1,+1,+1);
QPainter p(this);
QColor color = parentWidget()->palette().brush(QPalette::Window).color();
p.setPen(QPen(color,2));
p.setRenderHint(QPainter::Antialiasing);
p.drawRoundedRect(r, 6, 6);
}
};
Here's the result, where the bottom button is a normal QPushButton with no border radius, just to increase the difference visibility:
[image: XQPkv.gif]