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. Increase spacer size when scrollbar disappears
Forum Update on Monday, May 27th 2025

Increase spacer size when scrollbar disappears

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

    Hi !

    I am relatively new to Qt developpement, and i would like to ask you a question about a problem of UI design i encountered.
    I have a widget where there is a vertical layout composed of a QFrame (1) and a Spacer (3). In the QFrame there are 3 QFrame (4, 5, and 6) of fixed size, and a QScrollArea (2.) inside a QFrame.

    layoutscrollspacer.png

    The behaviour i want is the following : when the scrollbar is shown, the spacer is hidden, and when the main widget's size is increased :

    • if the scroll bar is still shown, the height of the widget surrounding the QScrollArea is increased, and the QScrollArea is expanded
    • if the scroll bar is hidden (the QScrollArea is entierly displayed), this is the size of the spacer that grows to occupy all the remaining space.

    It seems to me that this behaviour need to be programatically specified. I tried various solutions but i had no success for the moment. Are there anyone here who could help me find a good way to implement the behaviour i want?

    Thank you in advance !

    D 1 Reply Last reply
    0
    • D Dvassily

      Hi !

      I am relatively new to Qt developpement, and i would like to ask you a question about a problem of UI design i encountered.
      I have a widget where there is a vertical layout composed of a QFrame (1) and a Spacer (3). In the QFrame there are 3 QFrame (4, 5, and 6) of fixed size, and a QScrollArea (2.) inside a QFrame.

      layoutscrollspacer.png

      The behaviour i want is the following : when the scrollbar is shown, the spacer is hidden, and when the main widget's size is increased :

      • if the scroll bar is still shown, the height of the widget surrounding the QScrollArea is increased, and the QScrollArea is expanded
      • if the scroll bar is hidden (the QScrollArea is entierly displayed), this is the size of the spacer that grows to occupy all the remaining space.

      It seems to me that this behaviour need to be programatically specified. I tried various solutions but i had no success for the moment. Are there anyone here who could help me find a good way to implement the behaviour i want?

      Thank you in advance !

      D Offline
      D Offline
      Dvassily
      wrote on last edited by
      #2

      I found a potential solution but for it to work, i need to get the total size of the widget contained in the scroll area. Are there any function to obtain this piece of information?

      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