Qt之QtPainter:畫圓角矩形和多邊形

#include <QPainter>
#include <QFont>
void MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);

    painter.setPen(Qt::blue);
    QRectF rect(120, 10.0, 80.0, 80.0);
    painter.drawRoundedRect(rect, 20, 20); // round rect

    QPointF p2[3] = {
                    QPointF(120.0, 110.0),
                    QPointF(220.0, 110.0),
                    QPointF(220.0, 190.0)
                    };

    painter.drawPolygon(p2, 3); // drawing shape with points

    painter.end();
}

相關文章
相關標籤/搜索