首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

QPainter 无法显示图像?解决办法

2012-05-21 
QPainter 无法显示图像??我创建了一个项目,继承于QWidget,在构造函数中添加如下代码:C/C++ codeQPainter p

QPainter 无法显示图像??
我创建了一个项目,继承于QWidget,在构造函数中添加如下代码:

C/C++ code
    QPainter painter(this); QPixmap pix;     pix.load(":/Rotate/Resources/loading.png");        //painter.translate(50,50);                //使图片的中心作为旋转的中心    // painter.rotate(90);                //顺时针旋转90°  //painter.translate(-50,-50);        //将原点复位  painter.drawPixmap(0,0,100,100,pix);

可是现实不出该图片?求解!!

[解决办法]
Warning: When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by paintEvent(); that is unless the Qt::WA_PaintOutsidePaintEvent widget attribute is set. On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting.

你既然是在构造函数中添加的就看看这段话!

热点排行