QPainter::begin: Paint device returned engine == 0, type: 2 解决方法

出问题的代码段希望将painterdevice设置为图片,如下:


QPixmap picture;
QPainter painter;
	if(painter.begin(&picture))           // paint in picture
	{
		painter.drawEllipse(10,20, 80,70); // draw an ellipse
		painter.end();     
		picture.save("drawing.bmp");
	}

这时候begin返回false,因为picture是null,解决办法是初始化一个不为null的picture


QPixmap picture(640, 480);

你可能感兴趣的:(null)