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. Tab resizing issues
Forum Updated to NodeBB v4.3 + New Features

Tab resizing issues

Scheduled Pinned Locked Moved Unsolved Qt for Python
8 Posts 3 Posters 1.8k 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.
  • E Offline
    E Offline
    Ed Schneider
    wrote on last edited by
    #1

    Using PySide6 I have two tabs , one is called output and displays the current output. The second tab is called log and contains the history of all output. I want the information placed in the log to maintain the same size as it had in the output tab. The user should be able to scroll through the log. The log tab keeps growing in size. That unfortunately makes the output tab grow to the same size as the log tab even though the content of the output tab does not need that extra size. I understand that is the default. How do I override the default and make both the output tab and the log tab only as large as each needs to be?

    JonBJ 1 Reply Last reply
    0
    • E Ed Schneider

      Using PySide6 I have two tabs , one is called output and displays the current output. The second tab is called log and contains the history of all output. I want the information placed in the log to maintain the same size as it had in the output tab. The user should be able to scroll through the log. The log tab keeps growing in size. That unfortunately makes the output tab grow to the same size as the log tab even though the content of the output tab does not need that extra size. I understand that is the default. How do I override the default and make both the output tab and the log tab only as large as each needs to be?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Ed-Schneider said in Tab resizing issues:

      make both the output tab and the log tab only as large as each needs to be?

      I could be mistaken :) but I think tabs have to be the same size as each other. And they grow to the size of the largest. That is my recollection.

      [EDIT If that's wrong you could try setting a different fixed size on each tab widget and see how that behaves?]

      You can control the content you put on them with layouts, so you don't occupy unwanted areas, with scrollbars or spacers.

      E 1 Reply Last reply
      0
      • JonBJ JonB

        @Ed-Schneider said in Tab resizing issues:

        make both the output tab and the log tab only as large as each needs to be?

        I could be mistaken :) but I think tabs have to be the same size as each other. And they grow to the size of the largest. That is my recollection.

        [EDIT If that's wrong you could try setting a different fixed size on each tab widget and see how that behaves?]

        You can control the content you put on them with layouts, so you don't occupy unwanted areas, with scrollbars or spacers.

        E Offline
        E Offline
        Ed Schneider
        wrote on last edited by
        #3

        @JonB I would be happy if both were the same size as long as the log tab could be scrollable without impacting the size of the output tab. Now the size of the log tab impacts the size of the output tab. That's not what I want.

        JonBJ 1 Reply Last reply
        0
        • E Ed Schneider

          @JonB I would be happy if both were the same size as long as the log tab could be scrollable without impacting the size of the output tab. Now the size of the log tab impacts the size of the output tab. That's not what I want.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Ed-Schneider said in Tab resizing issues:

          as long as the log tab could be scrollable without impacting the size of the output tab

          So far as I know, if you put a scroll area (of a certain size) on one tab and content goes inside that, then it would not cause that tab or another tab to grow.

          You may have to provide a minimal example of your code.

          E 2 Replies Last reply
          0
          • JonBJ JonB

            @Ed-Schneider said in Tab resizing issues:

            as long as the log tab could be scrollable without impacting the size of the output tab

            So far as I know, if you put a scroll area (of a certain size) on one tab and content goes inside that, then it would not cause that tab or another tab to grow.

            You may have to provide a minimal example of your code.

            E Offline
            E Offline
            Ed Schneider
            wrote on last edited by
            #5

            @JonB I would love to share my code but this issue is embedded in a 15,000+ line application. Believe me adding to a scrollable area does enlarge its size and more importantly the size of other tabs. I am hoping that proper setting of resizing policies (on the tables going onto the tab and/or on the scrollable area) might avoid this. So far I've not found the solution. So I must humbly disagree with your assertion. Something more is involved here.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NikoC
              wrote on last edited by
              #6

              If you want to keep the sizes of your "output" and "log" tabs separate, while still making the "log" tab scrollable without influencing the "output" tab's size, a good practice is to place the content of each tab within a scrollable area. Be sure to configure the resizing policies appropriately. Good luck

              Empower your tech journey with valuable insights from https://softwaretested.com/

              E 1 Reply Last reply
              0
              • N NikoC

                If you want to keep the sizes of your "output" and "log" tabs separate, while still making the "log" tab scrollable without influencing the "output" tab's size, a good practice is to place the content of each tab within a scrollable area. Be sure to configure the resizing policies appropriately. Good luck

                E Offline
                E Offline
                Ed Schneider
                wrote on last edited by
                #7

                @NikoC I understand the goal here but I'm having trouble why it would make good sense to make the output tab scrollable. Can you explain?

                1 Reply Last reply
                0
                • JonBJ JonB

                  @Ed-Schneider said in Tab resizing issues:

                  as long as the log tab could be scrollable without impacting the size of the output tab

                  So far as I know, if you put a scroll area (of a certain size) on one tab and content goes inside that, then it would not cause that tab or another tab to grow.

                  You may have to provide a minimal example of your code.

                  E Offline
                  E Offline
                  Ed Schneider
                  wrote on last edited by
                  #8

                  @JonB I found on StackOverflow someone bringing up the same issue. It was 8 years old so I needed to bring it up to PySide6. It does indeed show the same problem, one tab needing to be large forcing the smaller tab to grow, needlessly to the same size. There is an answer which looks like it might work but I could not see how to implement it. In the code I've commented out code corresponding to the answer.

                  #!/bin/python
                  import sys
                  from PySide6 import QtGui, QtCore, QtWidgets
                  from PySide6.QtWidgets import (QApplication, QMainWindow, QTableWidget,
                                                 QTableWidgetItem, QVBoxLayout, QWidget, QTabWidget, QLayout, QSizePolicy)
                  
                  
                  class TabExample(QtWidgets.QWidget):
                      def __init__(self):
                          super(TabExample, self).__init__()
                          self.initUI()
                  
                      def initUI(self):
                          self.vbox_main = QtWidgets.QVBoxLayout()
                  
                          self.table_blank = QtWidgets.QTableWidget(10, 4)
                  
                          self.tabw = QtWidgets.QTabWidget()
                          self.tab_A = QtWidgets.QWidget()
                          self.vbox_A = QtWidgets.QVBoxLayout(self.tab_A)
                  
                          for i in range(40):
                              lab = QtWidgets.QLabel('label %d' %i)
                              self.vbox_A.addWidget(lab)
                  
                          self.tab_B = QtWidgets.QWidget()
                          self.vbox_B = QtWidgets.QVBoxLayout(self.tab_B)
                  
                          for i in range(5):
                              lab = QtWidgets.QLabel('labelB %d'%i)
                              self.vbox_B.addWidget(lab)
                  
                          #COMMENT OUT NEXT LINE TO SEE DESIRED SIZE OF TAB B
                          self.tabw.addTab(self.tab_A, 'Tab A')
                  
                          self.tabw.addTab(self.tab_B, 'Tab B')
                  
                          self.vbox_main.addWidget(self.table_blank, 1)
                          self.vbox_main.addWidget(self.tabw)
                  
                          self.setLayout(self.vbox_main)
                          self.setGeometry(0,0, 400, 600)
                          #self.move(QtGui.QDesktopWidget().availableGeometry().center() - self.frameGeometry().center())
                          self.show()
                  
                      # def __init__(self):
                      #     super(TabExample, self).__init__()
                      #     self.initUI()
                      #     #self.tabWidget_2.currentChanged.connect(self.updateSizes)
                      #     #self.tab_B.parentWidget().connect(lab,800,600)
                      #
                      #     self.tab_B.currentChanged.connect(self.updateSizes)
                      # def updateSizes(self):
                      #     for i in range(self.tabWidget_2.count()):
                      #         #self.tabWidget_2.widget(i).setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
                      #         self.tab_B.widget(i).setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
                      #
                      #     #current = self.tabWidget_2.currentWidget()
                      #     current = self.tab_B.currentWidget()
                      #     current.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
                  
                  
                  def main():
                      app = QtWidgets.QApplication(sys.argv)
                      tabExample = TabExample()
                      sys.exit(app.exec())
                  
                  if __name__ == "__main__":
                      main()
                  
                  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