我创建了一个项目,继承于QWidget,在构造函数中添加如下代码:
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.
你既然是在构造函数中添加的就看看这段话!
这样可以吗,都已经在painEvent里绘制完了,还能实时的rotate()吗?我用QTimeLine试了下,貌似旋转不起来啊