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. How do I make QScrollArea consume available vertical space inside a QVBoxLayout?
Forum Updated to NodeBB v4.3 + New Features

How do I make QScrollArea consume available vertical space inside a QVBoxLayout?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k 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.
  • A Offline
    A Offline
    aknudsen
    wrote on last edited by
    #1

    I have a QScrollArea wrapping a custom widget (with children laid out by a QVBoxLayout), and the QScrollArea is itself laid out by a QVBoxLayout. The wrapped widget is large enough to make a vertical scroll bar appear. Basically the (Python) code is like this:

    @
    layout = QtWidgets.QVBoxLayout(parent_widget)
    [...]
    form_scroll = QtWidgets.QScrollArea()

    form_widget is a custom widget with children laid out by QVBoxLayout

    form_scroll.setWidget(form_widget)
    form_scroll.setWidgetResizable(True)
    layout.addWidget(form_scroll, 1)
    @

    My problem is that the QScrollArea doesn't expand to consume available space in the vertical direction (horizontally it's fine). How do I make it expand vertically?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aknudsen
      wrote on last edited by
      #2

      I found the reason, which wasn't evident before the QScrollArea was introduced: I had called addStretch(1) on the layout object, which compressed the laid out widgets (including the QScrollArea).

      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