調用的模式是,通過querySubObject()和dynamicCall()兩個函數,
- 獲取對象
- 調用該對象的方法
QAxWidget word("Word.Application");
word.setProperty("Visible", true);
//獲取對象,調用該對象的方法
//獲取所有的工作文檔
QAxObject * documents = word.querySubObject("Documents");
documents->dynamicCall("Add (void)");
//獲取當前激活的文檔
QAxObject * document = word.querySubObject("ActiveDocument");
document->dynamicCall("SaveAs (const QString&)", QString("e:/docbyqt.doc"));
document->dynamicCall("Close (boolean)", false);
word.dynamicCall("Quit (void)");