Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Setting size of terminal spawned by QProcess
Qt 6.11 is out! See what's new in the release blog

Setting size of terminal spawned by QProcess

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 957 Views 1 Watching
  • 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.
  • J Offline
    J Offline
    julkip
    wrote on last edited by
    #1

    I am writing a widget that displays a terminal emulator within my programm

    class EmbeddedTerminal(QWidget):
        finished = pyqtSignal()
    
        def __init__(self, parent=None):
            super(EmbeddedTerminal, self).__init__(parent)
            self.process = QProcess(self)
            self.process.finished.connect(self.term_finished)
            self.terminal = QWidget(self)
            layout = QVBoxLayout(self)
            layout.addWidget(self.terminal)
            self.process.start('alacritty', ['--embed', str(int(self.winId()))])
    
        @pyqtSlot()
        def term_finished(self):
            self.finished.emit()
    

    When I start this widget, the terminal is always 640x480 pixels, but I want it do take as much space as possible. As far as I can tell there should be two ways
    First, the Layout should tell the Process to take the space (preferred way, but I don't know how).
    Second, I need the width and height in pixels of the available space, to calculate the dimensions of the terminal by hand and give it as a parameter in process.start().

    I really don't want to have to resort to the second option. Any suggestions on how to solve the issue? Maybe something completely different I did not think of?

    Thanks in advance!

    jsulmJ 1 Reply Last reply
    0
    • J julkip

      I am writing a widget that displays a terminal emulator within my programm

      class EmbeddedTerminal(QWidget):
          finished = pyqtSignal()
      
          def __init__(self, parent=None):
              super(EmbeddedTerminal, self).__init__(parent)
              self.process = QProcess(self)
              self.process.finished.connect(self.term_finished)
              self.terminal = QWidget(self)
              layout = QVBoxLayout(self)
              layout.addWidget(self.terminal)
              self.process.start('alacritty', ['--embed', str(int(self.winId()))])
      
          @pyqtSlot()
          def term_finished(self):
              self.finished.emit()
      

      When I start this widget, the terminal is always 640x480 pixels, but I want it do take as much space as possible. As far as I can tell there should be two ways
      First, the Layout should tell the Process to take the space (preferred way, but I don't know how).
      Second, I need the width and height in pixels of the available space, to calculate the dimensions of the terminal by hand and give it as a parameter in process.start().

      I really don't want to have to resort to the second option. Any suggestions on how to solve the issue? Maybe something completely different I did not think of?

      Thanks in advance!

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

      @julkip said in Setting size of terminal spawned by QProcess:

      self.process.start('alacritty', ['--embed', str(int(self.winId()))])

      You are providing the winId from your EmbeddedTerminal widget, not self.terminal inside EmbeddedTerminal.

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

      1 Reply Last reply
      0
      • J Offline
        J Offline
        julkip
        wrote on last edited by
        #3

        Changing self.winID() to self.terminal.winID() does not change the behaviour of the terminal unfortunately.

        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