• 10819阅读
  • 2回复

关于QThread的问题(Qpixmap,QPalette) [复制链接]

上一主题 下一主题
离线songxizg
 

只看楼主 倒序阅读 楼主  发表于: 2008-07-11
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
void test::run()
{
      QPalette palette2;
    palette2.setBrush(QPalette::Window,QBrush(QPixmap("/root/workspace/test/tu")));
        this->setPalette(palette2);
}

这个代码。运行时。警告:
QPixmap: It is not safe to use pixmaps outside the GUI thread


图片无法正常显示。哪位高人知道?指导一下。
离线huangliming
只看该作者 1楼 发表于: 2008-07-11
    In GUI applications, the main thread is also called the GUI thread because it's the only thread that is allowed to perform GUI-related operations.
    And the class QThread is non-Gui  thread,so you cann`t  use the GUI class Qpixmap in it.
离线wbyqy

只看该作者 2楼 发表于: 2009-04-29
给后来人留个参考

如楼上所说,在线程中不能使用QPixmap,但可以使用QImage,如有需要可以在线程外面将QImage转换成QPixmap
快速回复
限100 字节
 
上一个 下一个