这是主程序的小案例:
void Widget::paintEvent(QPaintEvent *){
QPainter *painter1 = new QPainter(this);
QPainter *painter2 = new QPainter(this);
delete painter1;
painter2->drawLine(50,50,200,100);
}
它正在崩溃。如果删除最后一行,我会收到以下警告消息:
QPaintDevice:无法销毁正在绘制的绘制设备