//for starf study
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QDebug>
#include<QPainterPath>
#include<QPainter>
#include<QPointF>
#include<QPolygonF>
#include<QVector>
#include <QRegion>
#include<QTransform>
#include<QFont>
//QPainterPath类提供了一个用于绘制操作的容器,可以构造和重用图形形状。
//绘制路径是由许多图形构建块组成的对象,例如矩形、椭圆、直线和曲线。
//QPainterPath对象可用于填充、勾勒和剪裁。
//与常规绘图操作相比,绘制路径的主要优点是复杂形状只需创建一次;然后调用qPaint::drawPath函数就可以多次绘制它们。
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::paintEvent(QPaintEvent *)
{
QPainterPath path(QPointF(19.5,25.5)); //创建一个QPainterPath对象,将给定的起始点作为其当前位置。
path.addEllipse(QRectF(10,10,100,50)); //在指定的边框内创建椭圆,并将其作为闭合子路径添加到绘制路径。
//void QPainterPath::addEllipse(qreal x, qreal y, qreal width, qreal height)
//void QPainterPath::addEllipse(const QPointF ¢er, qreal rx, qreal ry)
QVector<QPointF> points;
points.append(QPointF(80,30));
points.append(QPointF(80,130));
points.append(QPointF(180,130));
points.
QPainterPath方法功能(QT5.12)
最新推荐文章于 2023-10-31 13:51:42 发布
本文介绍了QPainterPath类的基本使用方法,包括如何创建和修改路径、添加各种形状、文本及曲线等,同时展示了路径的各种属性获取方式。

最低0.47元/天 解锁文章
1804

被折叠的 条评论
为什么被折叠?



