Qt 跨线程访问对象的有关问题 发布时间: 2013-10-10 14:14:51 作者: rapoo
Qt 跨线程访问对象的问题 1.在我的主线程里有一个QWidget* wid指针, 2.在我定义的一个QThread中,我需要用QPixmap::grabWidget(wid)这个方法对wid这个对象截图。 结果:程序在运行的时候报错。 ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread f8e7d38. Receiver '' (of type 'QWidget') was created in thread 3e5250", Qt?跨线程访问对象的问题 [解决办法] 你试试用信号槽把指针传过去[解决办法]
引用: 1.在我的主线程里有一个QWidget* wid指针, 2.在我定义的一个QThread中,我需要用QPixmap::grabWidget(wid)这个方法对wid这个对象截图。 结果:程序在运行的时候报错。 ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread f8e7d38. Receiver '' (of type 'QWidget') was created in thread 3e5250", 必须在主线程里截图。
[解决办法] 引用: Quote: 引用: 1.在我的主线程里有一个QWidget* wid指针, 2.在我定义的一个QThread中,我需要用QPixmap::grabWidget(wid)这个方法对wid这个对象截图。 结果:程序在运行的时候报错。 ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread f8e7d38. Receiver '' (of type 'QWidget') was created in thread 3e5250", 必须在主线程里截图。ui操作确实不能在别的线程里做。