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. adapting scrollarea when you expand or decrease intern widget
Forum Update on Monday, May 27th 2025

adapting scrollarea when you expand or decrease intern widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 1.2k 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.
  • A Albator
    4 Aug 2020, 07:19

    okay, with picture it's more explicative

    first i have this :
    scroll1.png

    3 widgets "graph" in a scroll area.
    with grow graph i expand the 3 widgets in the scroll area.

    void MainWindow::on_grow_clicked()
    {
        int w,h;
        w=2500;
        h=600;
    
        QSize grow_size(w,h);
    
        ui->graph->resize(grow_size);
        ui->graph2->resize(grow_size);
        ui->graph3->resize(grow_size);
    
        //ui->scrollAreaWidgetContents->update();
    
    }
    
    

    the 3 widgets grow correctly but :
    scroll2.png

    it's not perfect, i would like this when i grow graph :
    scroll3.png
    with the scroll vertical

    J Offline
    J Offline
    JonB
    wrote on 4 Aug 2020, 09:30 last edited by JonB 8 Apr 2020, 09:31
    #4

    @Albator
    You do not tell us how you are creating/adding your widgets. a QScrollArea only accepts a single widget to scroll, you talk about your 3 widgets, how are you adding those on the scroll area?

    Further, we do not know what your QScrollArea::setWidgetResizable() setting is.

    https://stackoverflow.com/questions/12781407/how-do-i-resize-the-contents-of-a-qscrollarea-as-more-widgets-are-placed-inside may be useful reading for you.

    1 Reply Last reply
    1
    • A Offline
      A Offline
      Albator
      wrote on 4 Aug 2020, 09:38 last edited by
      #5

      I added it from the mainwindows.ui design interface and drop the widgets in the scroll area.

      J 1 Reply Last reply 4 Aug 2020, 09:41
      0
      • A Albator
        4 Aug 2020, 09:38

        I added it from the mainwindows.ui design interface and drop the widgets in the scroll area.

        J Offline
        J Offline
        JonB
        wrote on 4 Aug 2020, 09:41 last edited by JonB 8 Apr 2020, 09:41
        #6

        @Albator
        I don't know what code that generates. Did that create a "holding" QWidget to drop your widgets onto? Did you put a layout onto that "holding" widget when you added your sub-widgets? Also what about the setWidgetResizable() setting? Did you look at the SO link?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Albator
          wrote on 4 Aug 2020, 09:49 last edited by
          #7

          okay so :
          1-
          when i create a scroll area with the design interface I don't know how to look at the code it created.
          2-
          scroll5.png
          yes, in the scroll area i have put a vertical layout.
          3-
          scroll4.png
          is enable
          4-
          What is SO link ?

          sorry in advance for my ignorance !

          J 1 Reply Last reply 4 Aug 2020, 10:06
          0
          • A Albator
            4 Aug 2020, 09:49

            okay so :
            1-
            when i create a scroll area with the design interface I don't know how to look at the code it created.
            2-
            scroll5.png
            yes, in the scroll area i have put a vertical layout.
            3-
            scroll4.png
            is enable
            4-
            What is SO link ?

            sorry in advance for my ignorance !

            J Offline
            J Offline
            JonB
            wrote on 4 Aug 2020, 10:06 last edited by JonB 8 Apr 2020, 10:07
            #8

            @Albator
            That stuff look about right.
            The SO (StackOverflow) link was the

            https://stackoverflow.com/questions/12781407/how-do-i-resize-the-contents-of-a-qscrollarea-as-more-widgets-are-placed-inside may be useful reading for you.

            I think you should read that, though I believe you have done the necessary.

            //ui->scrollAreaWidgetContents->update();

            I think you should try ui->scrollAreaWidgetContents->adjustSize() in case that resolves.

            I admit at this point I'm not sure! I try playing about with scroll settings till they work :) I don't know why you are getting a horizontal scrollbar but not a vertical one.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Albator
              wrote on 4 Aug 2020, 11:51 last edited by Albator 8 Apr 2020, 13:00
              #9

              I'll look at the SO link ;)
              then it's just in case I enlarge the widgets during the application run with the "grow graph" button.

              By setting the minimunsize parameter of my graph widgets to very wide and very high without using the buttons, the scroll area works fine so it's probably possible.

              parameters widgets graph :
              scroll6.png

              and the result :
              scroll7.png

              the problem it's just when i use the resize with button.

              i will try with adjustsize :)

              EDIT :
              adjustsize() doesn't work

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 4 Aug 2020, 17:54 last edited by
                #10

                I might be wrong but it looks like you are not using a layout on scrollAreaWidgetContents_2, are you ?

                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
                • A Offline
                  A Offline
                  Albator
                  wrote on 5 Aug 2020, 07:09 last edited by
                  #11

                  scroll8.png

                  of course i do

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Albator
                    wrote on 2 Sept 2020, 07:48 last edited by
                    #12

                    i up the post

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 2 Sept 2020, 18:17 last edited by SGaist 9 Feb 2020, 18:18
                      #13

                      Then maybe another silly question: are you sure your widgets are put in that layout ?

                      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
                      1
                      • A Offline
                        A Offline
                        Albator
                        wrote on 3 Sept 2020, 14:49 last edited by
                        #14

                        to be sure I did a test I changed the shape layout to see if the widgets would follow the modification.
                        And yes if I change the layout vertically my widgets adapt and the same for other formats, which proves that the widgets are in this layout.

                        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