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. Scrolling inside a Qtoolbox
QtWS25 Last Chance

Scrolling inside a Qtoolbox

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

    I have following hierarchy designed in Designer:

    QToolbox -> VerticalLayout -> GridLayout -> Pushbutton_1, Pushbutton_2,.... Pushbutton_n

    Basically, I have laid out many pushbuttons using a gridlayout which in turn is inside a VerticalLayout which in turn is inside a QToolbox page.

    There are many pushbuttons in the grid layout. I have set minimum width/height for all of them. Area required to layout all these push buttons can be larger than the area available in the page of the qtoolbox. I would like to automatically add a scroll bars to the page when this happens. I tried to use a scroll area as the parent of the vertical layout but it does not work. Any idea why?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should set the layout on a QWidget that you set on the QScrollArea.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        You should set the layout on a QWidget that you set on the QScrollArea.

        S Offline
        S Offline
        susa
        wrote on last edited by
        #3

        @SGaist Say inside a QFrame?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No need for a QFrame, use a QWidget.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            No need for a QFrame, use a QWidget.

            S Offline
            S Offline
            susa
            wrote on last edited by
            #5

            @SGaist I tried but does not seem to work. I purposely set the size of the layout to be larger than the widget so that widget will have to expand to accommodate the layout. Please see below for the heirarchy.

            14907386-9196-41b5-954a-3250a896cd70-image.png

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Since you have scrollAreaWidgetContent, remove "widget" and set the layout on scrollAreaWidgetContent.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                Since you have scrollAreaWidgetContent, remove "widget" and set the layout on scrollAreaWidgetContent.

                S Offline
                S Offline
                susa
                wrote on last edited by
                #7

                @SGaist I had to set the minimum sizes for the scrollAreaWidgetContent to get the effect. Which seems logical. However, why cannot I let the layout expand based on the constraints set and based on the size of the layout let the scroll area add scroll bars?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Did you remove the "widget" and applied the vertical layout on scrollAreaWidgetContent as suggested ?

                  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

                  • Login

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