2d graphics

沈博延
2023-12-01

QPainter can draw
geometric shapes (points, lines, rectangles, ellipses, arcs, chords, pie segments,
polygons, and Bézier curves), as well as pixmaps, images, and text. Furthermore,
QPainter supports advanced features such as antialiasing (for text and
shape edges), alpha blending, gradient filling, and vector paths. QPainter also
supports linear transformations, such as translation, rotation, shearing, and
scaling.

By reimplementing QWidget::paintEvent(), we can create custom widgets andexercise complete control over their appearance, as we saw in Chapter 5.

Forcustomizing the look and feel of predefined Qt widgets, we can also specify astyle sheet or create a QStyle subclass; we cover both of these approaches in

使用QPainter 画graphics 必须给他一个a paint device (typically a widget),

void MyWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this); //THIS IS  A widget
...
}

QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, 12, Qt::DashDotLine, Qt::RoundCap));
painter.setBrush(QBrush(Qt::green, Qt::SolidPattern));
painter.drawEllipse(80, 80, 400, 240);

转载于:https://www.cnblogs.com/gisbeginner/archive/2012/12/04/2800936.html

 类似资料:

相关阅读

相关文章

相关问答