您的位置:首页 > 产品设计 > UI/UE

QPixmap: It is not safe to use pixmaps outside the GUI thread

2014-04-02 16:45 357 查看
今天遇到这个问题

程序是次线程处理完数据后,发射一个信号给主线程,显示更新图片,然后提示QPixmap: It is not safe to use pixmaps outside the GUI thread

提示这个错误的时候两个线程之间的信号槽连接属性是Qt::DirectConnection,会提示不是在GUI线程里

后面属性改为默认的,不写,就不会出现这个问题了。

关键还是看连接属性的具体说明:

Qt::AutoConnection
0 (default) If the signal is emitted from a different thread than the receiving object, the signal is queued,
behaving as Qt::QueuedConnection. Otherwise, the slot is invoked directly, behaving as Qt::DirectConnection. The type of connection is determined when the signal is emitted.

Qt::DirectConnection 1
The slot is invoked immediately, when the signal is emitted.

Qt::QueuedConnection 2
The slot is invoked when control returns to the event loop of the receiver's thread. The slot is executed in the receiver's thread.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐