Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pyqt5.8:using QAxWidget to display word or pdf?

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    icerman
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • I Offline
      I Offline
      icerman
      wrote on last edited by
      #2

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

      jsulmJ D 2 Replies Last reply
      0
      • I icerman

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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • I icerman

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

          D Offline
          D Offline
          Devopia53
          wrote on last edited by
          #4

          @icerman

          You can simply used like this if exist doc.

          self.activex.setControl("E:/1.docx")
          
          1 Reply Last reply
          0
          • I Offline
            I Offline
            icerman
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              icerman
              wrote on last edited by
              #6
               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

              1 Reply Last reply
              0
              • I Offline
                I Offline
                icerman
                wrote on last edited by
                #7
                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 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved