How to draw a rect with only the bottom left border rounded?
-
How i could draw a rounded rect where only its bottom-left border has a radius of 8px?
My attempt resulted in this weird thing:

I'm trying to achieve something like this (without stylesheet)

class Widget : public QWidget { public: Widget(QWidget* parent) : QWidget(parent) {}; protected: void paintEvent(QPaintEvent *event) override { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); QRect rect(100, 100, 300, 100); QPainterPath path; path.moveTo(rect.left(), rect.top()); path.lineTo(rect.right(), rect.top()); path.lineTo(rect.right(), rect.bottom()); path.lineTo(rect.left() + 8, rect.bottom()); path.arcTo(QRectF(rect.bottomLeft() - QPointF(0, 8), QSizeF(16, 16)), 90, 90); path.lineTo(rect.left(), rect.top()); painter.setPen(Qt::red); painter.setBrush(Qt::black); painter.drawPath(path); } }; -
I got it working, only the bottom left corner rounded:
path.moveTo(mrect.bottomLeft() + QPointF(borderRadius, 0)); path.lineTo(mrect.bottomRight()); path.lineTo(mrect.topRight()); path.lineTo(mrect.topLeft()); path.lineTo(mrect.bottomLeft() + QPointF(0, -borderRadius)); path.quadTo(mrect.bottomLeft(), mrect.bottomLeft() + QPointF(borderRadius, 0)); -
How i could draw a rounded rect where only its bottom-left border has a radius of 8px?
My attempt resulted in this weird thing:

I'm trying to achieve something like this (without stylesheet)

class Widget : public QWidget { public: Widget(QWidget* parent) : QWidget(parent) {}; protected: void paintEvent(QPaintEvent *event) override { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); QRect rect(100, 100, 300, 100); QPainterPath path; path.moveTo(rect.left(), rect.top()); path.lineTo(rect.right(), rect.top()); path.lineTo(rect.right(), rect.bottom()); path.lineTo(rect.left() + 8, rect.bottom()); path.arcTo(QRectF(rect.bottomLeft() - QPointF(0, 8), QSizeF(16, 16)), 90, 90); path.lineTo(rect.left(), rect.top()); painter.setPen(Qt::red); painter.setBrush(Qt::black); painter.drawPath(path); } };@Ylvy
try for angles (not tested)
-45, -225path.moveTo(rect.left(), rect.top()); path.lineTo(rect.right(), rect.top()); path.lineTo(rect.right(), rect.bottom()); path.lineTo(rect.left() +16, rect.bottom()); path.arcTo(QRectF(rect.bottomLeft() +QPoint(0,-16), QSizeF(16,16)), -90,-90); path.lineTo(rect.left(), rect.top()); -
I got it working, only the bottom left corner rounded:
path.moveTo(mrect.bottomLeft() + QPointF(borderRadius, 0)); path.lineTo(mrect.bottomRight()); path.lineTo(mrect.topRight()); path.lineTo(mrect.topLeft()); path.lineTo(mrect.bottomLeft() + QPointF(0, -borderRadius)); path.quadTo(mrect.bottomLeft(), mrect.bottomLeft() + QPointF(borderRadius, 0)); -
Y Ylvy has marked this topic as solved on