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 Updated to NodeBB v4.3 + New Features

adapting scrollarea when you expand or decrease intern widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 1.4k 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.
  • AlbatorA Offline
    AlbatorA Offline
    Albator
    wrote on last edited by Albator
    #3

    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

    JonBJ 1 Reply Last reply
    0
    • AlbatorA Albator

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #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
      • AlbatorA Offline
        AlbatorA Offline
        Albator
        wrote on last edited by
        #5

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

        JonBJ 1 Reply Last reply
        0
        • AlbatorA Albator

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

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #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
          • AlbatorA Offline
            AlbatorA Offline
            Albator
            wrote on 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 !

            JonBJ 1 Reply Last reply
            0
            • AlbatorA Albator

              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 !

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #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
              • AlbatorA Offline
                AlbatorA Offline
                Albator
                wrote on last edited by Albator
                #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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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
                  • AlbatorA Offline
                    AlbatorA Offline
                    Albator
                    wrote on last edited by
                    #11

                    scroll8.png

                    of course i do

                    1 Reply Last reply
                    0
                    • AlbatorA Offline
                      AlbatorA Offline
                      Albator
                      wrote on last edited by
                      #12

                      i up the post

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by SGaist
                        #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
                        • AlbatorA Offline
                          AlbatorA Offline
                          Albator
                          wrote on 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