Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to Open a Qprocess that is GUI based
Qt 6.12 LTS is out! See what's new in the release blog

How to Open a Qprocess that is GUI based

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 624 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.
  • Q Offline
    Q Offline
    qtbuddy
    wrote on last edited by
    #1

    I would like to open a process which has its own GUI based interface inside my app. For example I have the a label called container and I like to add the output of the command evince -s mypdf.pdf inside that container.

    import sys
    from PyQt5.QtCore import QProcess
    from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
    
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
    
            self.container = QLabel("PDF Area")
            self.process = QProcess()
    
            self.setCentralWidget(self.container)
    
        def run(self, command):
            '''
                ....
    
                Code to attach command output ie a GUI window inside self.container
    
                ....
    
            '''
            
            self.process.start(command)
    
    
    app = QApplication(sys.argv)
    
    window = MainWindow()
    window.show()
    window.run('evince -s mypdf.pdf')
    app.exec()
    
    JonBJ 1 Reply Last reply
    0
    • Q qtbuddy

      I would like to open a process which has its own GUI based interface inside my app. For example I have the a label called container and I like to add the output of the command evince -s mypdf.pdf inside that container.

      import sys
      from PyQt5.QtCore import QProcess
      from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
      
      
      class MainWindow(QMainWindow):
          def __init__(self):
              super().__init__()
      
              self.container = QLabel("PDF Area")
              self.process = QProcess()
      
              self.setCentralWidget(self.container)
      
          def run(self, command):
              '''
                  ....
      
                  Code to attach command output ie a GUI window inside self.container
      
                  ....
      
              '''
              
              self.process.start(command)
      
      
      app = QApplication(sys.argv)
      
      window = MainWindow()
      window.show()
      window.run('evince -s mypdf.pdf')
      app.exec()
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @qtbuddy
      Hello and welcome.

      If you are determined to use evince for viewing PDF then my understanding is that you must launch it via QProcess, discover which window id it has used (somehow) and then embed that into a Qt widget via the code shown at e.g. https://stackoverflow.com/a/33760341/489865. I presume that "re-parents" the X window into the widget.

      If you do not require the evince external viewer then you might consider one of the ways of displaying PDF offered by Qt. There is https://doc.qt.io/qt-6/qtpdf-pdfviewer-example.html and https://www.kdab.com/browse-pdfs-in-a-qt-widgets-application/ among others, the Poppler libraries, and QWebEngineView can also be used to view PDF.

      1 Reply Last reply
      3

      • Login

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