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 window screen when all tabs of tabWidget closed

Resize window screen when all tabs of tabWidget closed

Scheduled Pinned Locked Moved Solved General and Desktop
qlabelqtabwidgetresizelayout
5 Posts 2 Posters 738 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.
  • B Offline
    B Offline
    BigBen
    wrote on last edited by
    #1

    I have a Desktop application, in which the left half of the screen is taken up by a label, and the right half of the screen is taken up by a tab widget. The centralwidget has a grid layout.

    I want the behaviour of the application to be such that, when all the tabs of the tab widget are closed, the application window resizes (becomes smaller) and displays just the left half (label on the left) of the application.

    As of now, when I close all the tabs of the tab widget, I have coded for the tab widget to hide (ui->tabWidget->hide()).
    However, when this happens, instead of the window resizing, the label on the left half of the screen expands horizontally, and takes up the space created due to the hiding of the tab widget.

    How can I resize the screen, instead of making the label take up the empty space?

    JonBJ 1 Reply Last reply
    0
    • B BigBen

      I have a Desktop application, in which the left half of the screen is taken up by a label, and the right half of the screen is taken up by a tab widget. The centralwidget has a grid layout.

      I want the behaviour of the application to be such that, when all the tabs of the tab widget are closed, the application window resizes (becomes smaller) and displays just the left half (label on the left) of the application.

      As of now, when I close all the tabs of the tab widget, I have coded for the tab widget to hide (ui->tabWidget->hide()).
      However, when this happens, instead of the window resizing, the label on the left half of the screen expands horizontally, and takes up the space created due to the hiding of the tab widget.

      How can I resize the screen, instead of making the label take up the empty space?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @BigBen
      My guess: the space occupied by the QTabWidget prior to hide() is now available to its parent, which it passes onto the label/grid layout/whatever.

      Can you maybe try a QWidget::adjustSize() on some parent widget (whatever is appropriate) which would allow it to recalculate? Is that it? I never know, I just play with layouts etc. till they work :) If you want to limit sizes I think you have to used fixed size.

      instead of the window resizing, the label on the left half of the screen expands horizontally

      I may have misunderstood what you want. I think you may have to reduce the size of you want the window to shrink, do you mean the whole outer window?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BigBen
        wrote on last edited by
        #3

        @JonB Thank you for your answer.

        Yes, I mean the whole outer window.

        JonBJ 1 Reply Last reply
        0
        • B BigBen

          @JonB Thank you for your answer.

          Yes, I mean the whole outer window.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @BigBen
          For the outer window I believe you will have to change the size yourself, I don't think it will shrink for you when its content gets smaller.

          1 Reply Last reply
          1
          • B Offline
            B Offline
            BigBen
            wrote on last edited by
            #5

            I see. Thank you.

            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