• 6051阅读
  • 3回复

多线程的slot问题 [复制链接]

上一主题 下一主题
离线zengo
 
只看楼主 倒序阅读 楼主  发表于: 2009-08-26
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
我把一段比较耗时的程序放在线程的slot中,通过主线程发送信号触发,为什么还会让界面无法响应。

文档里面有
Like other objects, QThread objects live in the thread where the object was created -- not in the thread that is created when QThread::run() is called. It is generally unsafe to provide slots in your QThread subclass, unless you protect the member variables with a mutex.

是不是线程里面最好不要有slot?
离线dbzhang800

只看该作者 1楼 发表于: 2009-08-26
耗时的程序段为什么不考虑在调用它的时候创建新线程呢?
离线allblue

只看该作者 2楼 发表于: 2009-08-26
不应该呀,好像不是这个原因造成的,多线程使用信号-槽机制是很普遍的事情,我觉得还要从别的地方着手
黑暗魔法
离线zengo
只看该作者 3楼 发表于: 2009-08-26
在A线程进行connect,连接B线程的slot
这个slot函数是不是还是在A线程执行
好像我用Qt::QueuedConnection连接方式也不行?
快速回复
限100 字节
 
上一个 下一个