自定义绘制
绘制圆环
void drawAnnulus(QPainter &painter, QRect rect, int start = 0, int end = 360, int width = 1, QColor color = QColor(0, 255, 0))
{
QPainterPath path, path2;
QRect outRect;
QRect innerRect;
outRect = rect;
innerRect = QRect(rect.x() + width, rect.y() + width,
rect.width() - 2 * width, rect.height() - 2 * width);
painter.save();
painter.fillRect(rect, Qt::black);
painter.setPen(Qt::NoPen);
painter.setBrush(color);
path.moveTo(rect.center());
path.arcTo(rect, start, end);
painter.drawPath(path);
path2.moveTo(innerRect.center());
path2.arcTo(innerRect, 0, 360);
painter.setBrush(Qt::black);
painter.drawPath(path2);
painter.restore();
}
1 画点
void drawPoint(const QPointF &position) | |
void drawPoint(const QPoint &position) | |
void drawPoint(int x, int y) | |
void drawPoints(const QPointF *points, int pointCount) | |
void drawPoints(const QPolygonF &points) | |
void drawPoints(const QPoint *points, int pointCount) | |
void drawPoints(const QPolygon &points) |
2 画线
void drawLine(const QLineF &line) | |
void drawLine(const QLine &line) | |
void drawLine(int x1, int y1, int x2, int y2) | |
void drawLine(const QPoint &p1, const QPoint &p2) | |
void drawLine(const QPointF &p1, const QPointF &p2) | |
void drawLines(const QLineF *lines, int lineCount) | |
void drawLines(const QVector &lines) | |
void drawLines(const QPointF *pointPairs, int lineCount) | |
void drawLines(const QVector &pointPairs) | |
void drawLines(const QLine *lines, int lineCount) | |
void drawLines(const QVector &lines) | |
void drawLines(const QPoint *pointPairs, int lineCount) | |
void drawLines(const QVector &pointPairs) |
3 画矩形
void drawRect(const QRectF &rectangle) | |
void drawRect(int x, int y, int width, int height) | |
void drawRect(const QRect &rectangle) | |
void drawRects(const QRectF *rectangles, int rectCount) | |
void drawRects(const QVector &rectangles) | |
void drawRects(const QRect *rectangles, int rectCount) | |
void drawRects(const QVector &rectangles) | |
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize) | |
void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = …) | |
void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = …) |