• 5033阅读
  • 9回复

一个月前没解决的问题,再来问问,关于COM在工作线程里使用的问题。 [复制链接]

上一主题 下一主题
离线darlings
 

只看楼主 正序阅读 楼主  发表于: 2010-01-26
前段时间弄了个程序,使用了WORD.APPLICATION,用如下方法创建:
    QAxWidget *wordActive = new QAxWidget;
    wordActive->setControl("Word.Application");
但是不太清楚怎么把对这个COM接口的调用放在工作线程里去执行,有做过的来指点一下吧。谢谢。
离线hehui

只看该作者 9楼 发表于: 2010-03-03
UI事件处理线程只有一个qAPP!
不可能出现第二个UI处理线程的~
离线darlings

只看该作者 8楼 发表于: 2010-01-26
引用第7楼dbzhang800于2010-01-26 13:06发表的  :

谢谢,我再想想吧,不知道要怎么才能在工作线程里处理。
离线dbzhang800

只看该作者 7楼 发表于: 2010-01-26
引用第6楼darlings于2010-01-26 12:35发表的  :
重入是什么意思呀?

reentrancy

我对多线程不太了解,摘录的是Qt的manual中的内容,打开你的 assistant 就能找到

http://qt.nokia.com/doc/4.6/threads-reentrancy.html
the terms reentrant and thread-safe are used to mark classes and functions to indicate how they can be used in multithread applications:

    * A thread-safe function can be called simultaneously from multiple threads, even when the invocations use shared data, because all references to the shared data are serialized.
    * A reentrant function can also be called simultaneously from multiple threads, but only if each invocation uses its own data.

Hence, a thread-safe function is always reentrant, but a reentrant function is not always thread-safe.


http://qt.nokia.com/doc/4.6/threads-qobject.html
Although QObject is reentrant, the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread. As noted earlier, QCoreApplication::exec() must also be called from that thread.
离线darlings

只看该作者 6楼 发表于: 2010-01-26
引用第4楼dbzhang800于2010-01-26 09:54发表的  :
QAxWidget 是 QWidget 的派生类,而 QWidget 和它的所有子类都是不可重入的。

重入是什么意思呀?
离线benbenmajia

只看该作者 5楼 发表于: 2010-01-26
我不晓得QT下的线程,但是应该和C++下的线程有很大的关联,LZ参考下C++的多线程应该会有帮助
安然.....
离线dbzhang800

只看该作者 4楼 发表于: 2010-01-26
引用第3楼darlings于2010-01-26 09:49发表的  :
线程创建我也是粗略地看了下,代码如下:
//线程
    MyThread* thread= new MyThread;
    thread->wordActive = wordActive;
    thread->start();
.......


QAxWidget 是 QWidget 的派生类,而 QWidget 和它的所有子类都是不可重入的。
离线darlings

只看该作者 3楼 发表于: 2010-01-26
线程创建我也是粗略地看了下,代码如下:
//线程
    MyThread* thread= new MyThread;
    thread->wordActive = wordActive;
    thread->start();
在UI线程里的很多操作,放在工作线程里,对接口的调用方法都会返回0,不知道为什么。
离线benbenmajia

只看该作者 2楼 发表于: 2010-01-26
再召唤,刚看过些线程和com的东西,COM的调用倒是知道,不过LZ说在线程中调用,你的多线程?
安然.....
离线午小夜

只看该作者 1楼 发表于: 2010-01-26
不懂COM。。。召喚白老師。
[操作系统版本]  Windows XP;Linux Ubuntu;Linux Fedora;
[Qt SDK版本]    4.7.0
[SDK 发布日期]  2010.05
[IDE(集成开发环境)] QtCreator
个人网页:http://hi.baidu.com/午小夜
學歷:Royal Jalidon
快速回复
限100 字节
 
上一个 下一个