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. Resize dialog with a scrollbar
Forum Update on Monday, May 27th 2025

Resize dialog with a scrollbar

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.0k 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.
  • N Offline
    N Offline
    nnzz
    wrote on 22 Jan 2019, 09:48 last edited by
    #1

    Hi, I have a dialog with a vertical scroll bar, and some widgets that change their size according to the user actions.
    If I don't add the scroll bar the dialog resizes automatically but I was asked to add a scrollbar, and now when some controls are hidden the dialog stays the same, and the vertical scrollbar is adjusted. I want the dialog to resize automatically to the height which does not require the scrollbar, and in addition allow the user to change the height as he/she pleases (thus I need the scrollbar).
    I tried all kinds of solutions, the one that works best is a little ugly:

    1. Remove the scrollbar from the layout
    2. Call adjustSize()
    3. Restore the scrollbar

    problems with this solution:

    1. ugly
    2. doesn't adjust to the dialog's minimal size, only for exapnding
    J 1 Reply Last reply 22 Jan 2019, 22:28
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Jan 2019, 22:16 last edited by
      #2

      Hi,

      What are these user actions ?

      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
      • N nnzz
        22 Jan 2019, 09:48

        Hi, I have a dialog with a vertical scroll bar, and some widgets that change their size according to the user actions.
        If I don't add the scroll bar the dialog resizes automatically but I was asked to add a scrollbar, and now when some controls are hidden the dialog stays the same, and the vertical scrollbar is adjusted. I want the dialog to resize automatically to the height which does not require the scrollbar, and in addition allow the user to change the height as he/she pleases (thus I need the scrollbar).
        I tried all kinds of solutions, the one that works best is a little ugly:

        1. Remove the scrollbar from the layout
        2. Call adjustSize()
        3. Restore the scrollbar

        problems with this solution:

        1. ugly
        2. doesn't adjust to the dialog's minimal size, only for exapnding
        J Offline
        J Offline
        JonB
        wrote on 22 Jan 2019, 22:28 last edited by
        #3

        @nnzz
        Sorry, I don't understand (that often seems to happen...).

        • If you're going "to resize automatically to the height which does not require the scrollbar", why do you then want a scrollbar?

        • You also say "in addition allow the user to change the height as he/she pleases (thus I need the scrollbar)" The normal way to resize a dialog is to make it resizable so the user drags the edges to desired size. Why would you want a scrollbar for this?

        :confused:

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nnzz
          wrote on 23 Jan 2019, 07:31 last edited by
          #4

          Sorry... my dialog has 3 checkboxes, each controls the visibility of a frame.
          Thus, when a check box is activated the dialog height changes.
          Before I added the scrollbar the automatic resizing was perfect, but when all frames are shown the dialog becomes rather tall so I added a vertical scrollbar.
          now the dialog height stays fixed.
          I would like the same behavior as before, which is to resize to full length,
          with the addition that if the user drags the bottom to change the height a scroll bar appears.
          What is the proper way to do that?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 23 Jan 2019, 22:48 last edited by
            #5

            Did you set the widgetResizable property to true ?

            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

            1/5

            22 Jan 2019, 09:48

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved