pyqt5.8:using QAxWidget to display word or pdf?
Unsolved
General and Desktop
-
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
all these activex can be display correctly with my IE
-
@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
-
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
-
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