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. Adjust the parent size when child is hidden

Adjust the parent size when child is hidden

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.9k 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.
  • N Offline
    N Offline
    nen777w
    wrote on last edited by
    #1

    I have the following dialog structure:
    !http://files.rsdn.ru/38394/dialog_struct.jpg(dialog structure)!

    It's a splitter with frames where is each frame contain button and scroll area.
    When the user uncheck the button the scroll area is hiding. And result is:
    !http://files.rsdn.ru/38394/window_splitter.jpg(result)!

    So the button just aligned on the center of frame.
    But I want another behavior like on the following image:
    !http://files.rsdn.ru/38394/window_splitter_2.jpg(desired result)!

    If I understand correctly I just need call adjustSize() for the frame when I hide the scroller:
    @void MainWindow::on_btn_1(bool b)
    {
    ui->scrollArea->setVisible(b);
    ui->frame->adjustSize();
    }@

    But unfortunately it's does not work :-(
    Thanks.

    "Link to the source code:":http://files.rsdn.ru/38394/QtTest2.zip

    1 Reply Last reply
    0
    • 8 Offline
      8 Offline
      8majkel8
      wrote on last edited by
      #2

      use QToolBox instead.

      just ui->scrollArea->setVisible(b); should work

      also remove frame, frame_2, frame_3 and use vertical layout on scrollArea_global. Add vertical spacer at bottom to handle case when all buttons are off.

      PS: you don't have to add separate layout on widget. Just right click on control and select layout from there.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nen777w
        wrote on last edited by
        #3

        Thanks... but I need behavior (with the same set of controls) as I subscribed above.
        I just simplify my real case in this example to show the behavior that I need to get.

        p.s.
        I tried use the spacer but in this case splitter does not work.

        1 Reply Last reply
        0
        • 8 Offline
          8 Offline
          8majkel8
          wrote on last edited by
          #4

          sorry I previously missed qsplitter messing around ;-)

          You could use something like this

          @ui->frame->setMaximumHeight(b ? 99999 : ui->pushButton->height());@

          or

          @ui->frame->setMaximumHeight(b ? 99999 : 0);@

          if you set frame's minimumSize

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nen777w
            wrote on last edited by
            #5

            It's work!
            Thanks a lot!

            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