Qt里面,要想画图,只有把画图的过程放入paintEvent()
方法中,每次窗口变化时会回调paintEvent()
方法
Paint events are sent to widgets that need to update themselves, for
instance when part of a widget is exposed because a covering widget was
moved.
QPainter
The QPainter class performs low-level painting on widgets and other paint devices.
QPainter
类对象作用于继承QPaintDevice
类的对象
QPaintDevice
QPainter对象可以在QPaintDevice上进行绘画操作
常用的QPaintDevice
子类有QWidget, QPixmap, QImage
示例
//画图并保存为图片
void SomeWidget::painterEvent()
{
QImage image(