pyqt5.8:using QAxWidget to display word or pdf?



  • 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");
    

    alt text
    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
    alt text

    all these activex can be display correctly with my IE
    alt text



  • can anybody give me some advice?I need your help!


  • Moderators



  • @icerman

    You can simply used like this if exist doc.

    self.activex.setControl("E:/1.docx")
    


  • 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.



  •  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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.