QPainter类
void Widget::paintEvent(QPaintEvent *event)
{
// QPainter painter(this); //实例化画家对象,this指定的是绘图设备
// QPen pen(Qt::red);
// painter.setPen(pen);
// QBrush brush(Qt::cyan);
// brush.setStyle(Qt::Dense7Pattern);
// painter.setBrush(brush);
// painter.drawLine(QPoint(0,0),QPoint(100,100));
// painter.drawEllipse(QPoint(100,100),50,50);
// painter.drawText(QRect(100,200,200,50),"好好学习,天天向上");
//--------------------------------
QPainter painter(this); //实例化画家对象,this指定的是绘图设备
painter.drawPixmap(pox,100,QPixmap(":/pikaqiu.gif"));
}
手动调用 用update();