• 8243阅读
  • 4回复

[提问]关于rotate旋转函数的 [复制链接]

上一主题 下一主题
离线a2263667
 

只看楼主 倒序阅读 楼主  发表于: 2011-05-01
我想实现按一个按钮后让一幅图片转起来。
我先用  void Dialog::paintEvent(QPaintEvent *event)  事件的方法加入一张图片。
之后想用 void Dialog::on_startBtn_clicked()  为点击后的响应事件。
但是总是出现
QPainter::begin: Paint device returned engine == 0, type: 1

QPainter::translate: Painter not active
QPainter::rotate: Painter not active
QPainter::translate: Painter not active
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::translate: Painter not active
QPainter::rotate: Painter not active
QPainter::translate: Painter not active
QPaintDevice: Cannot destroy paint device that is being painted


请问是怎么回事?
或者有什么其他方法可以实现让它转起来?

离线a2263667

只看该作者 1楼 发表于: 2011-05-01
已解决
附件: roulette_test.rar (414 K) 下载次数:32
离线wxj120bw

只看该作者 2楼 发表于: 2011-05-01
引用楼主a2263667于2011-05-01 03:17发表的 关于rotate旋转函数的 :
我想实现按一个按钮后让一幅图片转起来。
我先用  void Dialog::paintEvent(QPaintEvent *event)  事件的方法加入一张图片。
之后想用 void Dialog::on_startBtn_clicked()  为点击后的响应事件。
但是总是出现
QPainter::begin: Paint device returned engine == 0, type: 1
.......

看下这个帮助文档
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.
离线naruto

只看该作者 3楼 发表于: 2012-03-20
请问你是怎么解决的?我也遇到了类似的问题
离线jdwx

只看该作者 4楼 发表于: 2012-03-20
回 3楼(naruto) 的帖子
Qt只能在paintEvent();里绘图。
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
快速回复
限100 字节
 
上一个 下一个