pyqt5.8:using QAxWidget to display word or pdf?
-
wrote on 27 Apr 2017, 08:45 last edited by
Hi :
I am using pyqt5.8,python3.6,eric6, win10(64),and now I want display word with QAxWidget,the code like the following:
self.activex = QAxContainer.QAxWidget() self.activex.setFocusPolicy(QtCore.Qt.StrongFocus) self.activex.setControl("Word.Application") self.activex.dynamicCall("Open(QString)","E:\\1.doc");
but it can not work correctly,it only show me the black screen,so I want to using dsoframer.ocx to display word file,self.activex = QAxContainer.QAxWidget() self.activex.setFocusPolicy(QtCore.Qt.StrongFocus) self.activex.setControl("{00460182-9E5E-11d5-B7C8-B8269041DD57}")
it give me nothing,it seems that it can not read clsid,and can not display activex
-
wrote on 2 May 2017, 07:58 last edited by
can anybody give me some advice?I need your help!
-
@icerman You should first check the return values from http://doc.qt.io/qt-5/qaxbase.html#control-prop and http://doc.qt.io/qt-5/qaxbase.html#dynamicCall-1
-
wrote on 2 May 2017, 09:54 last edited by
HI Devopia53 :
This is just a test,for example ,I have a dsoframer.ocx activex,it's clsid is "{00460182-9E5E-11d5-B7C8-B8269041DD57}",I want it to display in pyqt5 application,and now it can not work correctly.
-
wrote on 2 May 2017, 09:59 last edited by
try: self.activex = QAxContainer.QAxWidget() self.activex.setFocusPolicy(QtCore.Qt.StrongFocus) contr = self.activex.setControl("{00460182-9E5E-11d5-B7C8-B8269041DD57}") print(contr) self.activex.dynamicCall("Open(string)", "E:\\1.doc") self.activex.show() self.verticalLayout.addWidget(self.activex) except Exception: print(str(Exception))
it print "False",and give me no any exception message
-
wrote on 2 May 2017, 10:10 last edited by
self.activex = QAxContainer.QAxWidget() self.activex.setFocusPolicy(QtCore.Qt.StrongFocus) contr = self.activex.setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}") print(contr) self.activex.setObjectName("WebBrowser") self.activex.setProperty("DisplayScrollBars",True); self.verticalLayout.addWidget(self.activex) self.activex.dynamicCall('Navigate(const QString&)', "www.baidu.com")
if using IE,It can work correctly,and it print True
1/7