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. [Solved] How to make QTableWidget fill entire area of available space?
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to make QTableWidget fill entire area of available space?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 9.7k 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.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,
    In the Main Window of my application I have a QFrame (say frame1) with GridLayout. I have added one more QFrame (say frame2) in it along with horizontal & vertical spacers through .ui file.
    I had created frame2 for a particular scenario, but I dont need it in current scenario.
    So I am removing it from frame1 & deleting it.
    Now I am creating a QTableWidget by code & adding it in position 0,0 of gridlayout of frame1.
    The problem is that initially it is created with a fixed size. Now when I am adding rows & columns its size is not increasing & it is creating Scroll Bar's. Could it be because of the Spacer's? I want the table to adjust its size according to the no of rows & columns. I do not want it to create Scroll bar's & even if it its size increasing more than my window than I have a QScrollArea which is the parent of frame1. So it will create the Scroll bar's.
    So how do I get the required behaviour?
    Maybe it is confusing to get the question, please ask if you did not understand anything.
    Thank You.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      You need to provide some code about how you are implementing, try to set the sizePolicy,

      @yourTableWiget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);@

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mario84
        wrote on last edited by
        #3

        You'll probably have to resize your TableWidget yourself, calculating the necessary space each time an item is added or removed. (Be aware of the size policy in this case, perhaps you'll have to also change the minimum/maximum sizes each time)
        By default, changing the contents of a tablewidget won't affect the outer size of the widget, no matter how the layout / spacers and size policies around it are set.
        So this will be quite a complicated task...

        1 Reply Last reply
        0
        • CAD_codingC Offline
          CAD_codingC Offline
          CAD_coding
          wrote on last edited by
          #4

          @Sam I will try that.
          @Mr. Universe Thank You! Looks like I have some hard work ahead :)

          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