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. Making a QScrollArea take only the space it's contents need
Forum Updated to NodeBB v4.3 + New Features

Making a QScrollArea take only the space it's contents need

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 243 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.
  • W Offline
    W Offline
    Warchamp7
    wrote on last edited by
    #1

    I have a QDialog in Qt Creator with a horizontal layout that contains two vertical layout columns.

    In the left column, I have a QGridBox that gets populated. I'm trying to get the left column to expand only as much as needed to fit the contents in the grid, and allocate the remaining space to the right column.

    The issue I am running into is that I end up with a horizontal scrollbar on the left column. Setting both size policies to expanding means each column gets an equal amount of the available space, which can result in the left column being too small for it's contents.

    With the right column set to preferred, I end up with a gap of space in the middle, as the left column expands to the available space beyond what it needs for the grid items.

    How can I make the right column take up the remaining available space, without it taking from the left one? If I insert some example items into the Grid Layout in Qt Creator, I can see that the grid and parent scroll contents widget have their geometry size to fit those items, but the container QScrollArea does not.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      django.Reinhard
      wrote on last edited by
      #2

      I fiddled with QScrollArea too recently.

      My advice: try to solve column layout without QScrollArea. Check QWidget::minimumSizeHint.
      When your column layout works without QScrollArea, then adding QScrollArea with setWidgetResizable(true) should do the job. At least it worked for me.

      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