您的位置:首页 > 编程语言 > Qt开发

Qt中QPainter的问题

2017-08-22 14:43 323 查看
我在进行2D绘制时,采用了QPainter的方法,想在QLabel上绘图,所以直接就QPainter painter, painter.begin(label);报错QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::end: Painter not active, aborted

QWidget::paintEngine: Should no longer be called。

然后我通过在QPixMap上画再通过painter.begin(label); painter.drawPixmap(0,0, pixmap);
还是同样的报错。

最后索性就在pixmap上画图,然后painter.begin(this); paint.drawPixmap(label.x, label.y pixmap);一了百了。

前提是绘图代码得写在PaintEvent中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qt 2d 绘图