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. How to automatically resize Qtable widget according to the item.
Forum Updated to NodeBB v4.3 + New Features

How to automatically resize Qtable widget according to the item.

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

    I want to resize my table widget according to my item which I am giving through hardcode.
    I used bellow code but is not resizing

    self.statTable.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Please show the code you use to initialize that widget and its content.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Y 1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yashi95
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Please show the code you use to initialize that widget and its content.

          Y Offline
          Y Offline
          yashi95
          wrote on last edited by
          #4

          @SGaist

          self.tblDropdown = self.dialogDropdown.findChild(QTableWidget, "tbl_dropdown")
          dropdownList = args[2]["list"]
          for i in range(len(dropdownList)):
              self.tblDropdown.insertRow(i)
              self.tblDropdown.setItem(i, 0, QTableWidgetItem(dropdownList[i]))
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Why do you need findChild in the first place ?

            You need to call resize manually once you added all the items you want.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Y 1 Reply Last reply
            0
            • SGaistS SGaist

              Why do you need findChild in the first place ?

              You need to call resize manually once you added all the items you want.

              Y Offline
              Y Offline
              yashi95
              wrote on last edited by
              #6

              @SGaist

              I did findchild for table so, that I can add my item in table.
              for resizing i am adding "self.statTable.setSizeAdjustPolicy(
              QtWidgets.QAbstractScrollArea.AdjustToContents)" is this correct to resize the table bcz automatically table is not resizing.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Using findChild like that is not a good sign. It looks like you do not really know where that QTableWidget is located or that you are trying to fill it from somewhere not appropriate.

                No it's not, QTableWidget does not contain a widget. It draws its content hence my suggestion about calling resize once you have filled it.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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