void MyThread::run(){
CoInitialize(NULL);
QAxWidget *word=new QAxWidget("Word.Application", 0, Qt::MSWindowsOwnDC);
QAxObject * documents = word->querySubObject("Documents");
documents->dynamicCall("Add(QString)",QString::fromLocal8Bit("E:/temple/cover.doc"));
QAxObject *document=word->querySubObject("ActiveDocument");
// 将文件另存为docbyqt.doc,关闭工作文档,退出应用程序
document->dynamicCall("SaveAs (const QString&)", QString("E:/1/0.封面.doc"));
document->dynamicCall("Close (boolean)", false); word->dynamicCall("Quit()");
CoUninitialize();
}
我使用了 CoInitialize(NULL)和CoUninitialize()为什么在运行的时候还是报错。
void MainWindow::on_pushButton_clicked(){ MyThread = new MyThread(this); MyThread->start(QThread::LowestPriority);}错误信息如下:
ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file [url]kernel\qwidget.cpp, line 1133[/url]
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
QObject::~QObject: Timers cannot be stopped from another thread