当前位置: 代码迷 >> QT开发 >> QPainter 无法显示图像?解决办法
  详细解决方案

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

热度:539   发布时间:2016-04-25 04:48:37.0
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.

你既然是在构造函数中添加的就看看这段话!
  相关解决方案