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. QWidget is automatically resized beyond maximized
QtWS25 Last Chance

QWidget is automatically resized beyond maximized

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.7k 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.
  • P Offline
    P Offline
    panch
    wrote on last edited by panch
    #1

    Hi all!

    I have a QWidget, that only holds a single widget inside - a QTabWidget.
    This TabWidget is populated on runtime with child dialogs (QWidget dialogs).

    When one of these tabs are activated - the application window is resized so that the bottom is not visible anymore. Somehow this specific dialog resizes the application window. How can it do that? Even when I have maximized my app window before pressing this specific tab.
    It is only the one tab that does this - the others do not affect the window size.
    Inside this tab are general widgets, groupboxes, frames etc.

    Thanks in advance

    JonBJ 1 Reply Last reply
    0
    • P panch

      Hi all!

      I have a QWidget, that only holds a single widget inside - a QTabWidget.
      This TabWidget is populated on runtime with child dialogs (QWidget dialogs).

      When one of these tabs are activated - the application window is resized so that the bottom is not visible anymore. Somehow this specific dialog resizes the application window. How can it do that? Even when I have maximized my app window before pressing this specific tab.
      It is only the one tab that does this - the others do not affect the window size.
      Inside this tab are general widgets, groupboxes, frames etc.

      Thanks in advance

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

      @panch
      I don't understand why a tab widget would hold dialogs, but never mind.

      When you have tabs, the size of the overall is the size of whatever is the largest area of widgets on any of the tabs. That in turn can cause the main window to grow in size to accommodate, which seems to be what you are describing.

      And this resizing does not wait to happen till a tab is displayed --- it happens immediately if the widgets are placed on the tab in the constructor. That also means that it does not take into account whatever you might do which might change the tab's content size at run-time, e.g. to make it smaller, when it gets displayed.

      So you need to look at whichever tab you say is causing the window to get big, all the widgets on it at constructor time, and see what is causing the overall size.

      I had to do this recently to track down which among the 20-odd stacked tabs we had was causing all the tabs to be so large.

      EDIT: Re-reading, not sure how this applies to what you describe. Instead, if I understand you right, a tab with a bunch of widgets on it will grow to the size of all those widgets. You have to set the tab widget's size if you want to limit that to not grow too big. Or put scroll areas on it. I think.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        panch
        wrote on last edited by
        #3

        @JonB said in QWidget is automatically resized beyond maximized:

        I don't understand why a tab widget would hold dialogs, but never mind.

        If you make a tab based application - would you program all your functionality in that single dialog holding the QTabWidget? And what if you have multiple tabs that have the exact same layout and functionality - would you then program X number of identical layouts?
        I tend to encapsulate all functionality for each tab within a child dialog, which makes it modular and easy to reuse. But if there is something I have missed, please enlighten me :)

        @JonB said in QWidget is automatically resized beyond maximized:

        When you have tabs, the size of the overall is the size of whatever is the largest area of widgets on any of the tabs. That in turn can cause the main window to grow in size to accommodate, which seems to be what you are describing.

        And this resizing does not wait to happen till a tab is displayed --- it happens immediately if the widgets are placed on the tab in the constructor. That also means that it does not take into account whatever you might do which might change the tab's content size at run-time, e.g. to make it smaller, when it gets displayed.

        So you need to look at whichever tab you say is causing the window to get big, all the widgets on it at constructor time, and see what is causing the overall size.

        I had to do this recently to track down which among the 20-odd stacked tabs we had was causing all the tabs to be so large.

        Well the dialog inside this tab does not have any fixed or minimum size widgets, they should all be dynamic sizes - which is the reason why I don't understand why it resizes the full window. But I will have a look again.

        @JonB said in QWidget is automatically resized beyond maximized:

        EDIT: Re-reading, not sure how this applies to what you describe. Instead, if I understand you right, a tab with a bunch of widgets on it will grow to the size of all those widgets. You have to set the tab widget's size if you want to limit that to not grow too big. Or put scroll areas on it. I think.

        I think how you understood it in the top was right :) so I will just ignore this last part :)

        Thanks for the comments. Maybe I should try to start by making my child dialog scrollable to see if I then get a fixed window size.

        JonBJ 1 Reply Last reply
        0
        • P panch

          @JonB said in QWidget is automatically resized beyond maximized:

          I don't understand why a tab widget would hold dialogs, but never mind.

          If you make a tab based application - would you program all your functionality in that single dialog holding the QTabWidget? And what if you have multiple tabs that have the exact same layout and functionality - would you then program X number of identical layouts?
          I tend to encapsulate all functionality for each tab within a child dialog, which makes it modular and easy to reuse. But if there is something I have missed, please enlighten me :)

          @JonB said in QWidget is automatically resized beyond maximized:

          When you have tabs, the size of the overall is the size of whatever is the largest area of widgets on any of the tabs. That in turn can cause the main window to grow in size to accommodate, which seems to be what you are describing.

          And this resizing does not wait to happen till a tab is displayed --- it happens immediately if the widgets are placed on the tab in the constructor. That also means that it does not take into account whatever you might do which might change the tab's content size at run-time, e.g. to make it smaller, when it gets displayed.

          So you need to look at whichever tab you say is causing the window to get big, all the widgets on it at constructor time, and see what is causing the overall size.

          I had to do this recently to track down which among the 20-odd stacked tabs we had was causing all the tabs to be so large.

          Well the dialog inside this tab does not have any fixed or minimum size widgets, they should all be dynamic sizes - which is the reason why I don't understand why it resizes the full window. But I will have a look again.

          @JonB said in QWidget is automatically resized beyond maximized:

          EDIT: Re-reading, not sure how this applies to what you describe. Instead, if I understand you right, a tab with a bunch of widgets on it will grow to the size of all those widgets. You have to set the tab widget's size if you want to limit that to not grow too big. Or put scroll areas on it. I think.

          I think how you understood it in the top was right :) so I will just ignore this last part :)

          Thanks for the comments. Maybe I should try to start by making my child dialog scrollable to see if I then get a fixed window size.

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

          @panch

          Well the dialog inside this tab does not have any fixed or minimum size widgets, they should all be dynamic sizes

          It depends when/how these "dynamic sizes" are calculated.

          (In my experience:) When you place all your children/dialogs on tabs, the only code which executes at that point is the constructor stuff for the children. That determines their size for the purpose of gauging the total size of the tab, which is that of whichever is the largest.

          If the way it works is that when a child is shown that would cause changes in its size --- for example, perhaps certain child widgets get hidden, or perhaps they resize to their content --- that will not be taken into account at the time the tab is initialized/constructed. Hence their "initialization"-time sizes may be larger than their actual "run"-time sizes would ever turn out to be.

          On top of this, I have no experience with placing dialogs on tabs, if I understand that is what you say you do. If that is the case, I do not know how it is calculated what size the tab is given that it has a child widget which is a dialog.

          Otherwise, if I am off the track, you will have to play with the widgets on the specific tab/dialog which is the cause of the "too large" to see if you can figure what is going on. I can only say that when I started Qt (recently) and inherited a stacked tab which turned out to have one tab which was larger than all the others and caused big resizing, that is what I had to do to reduce the overall size.

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

            Hi,

            Can you post a minimal compilable example that shows that behaviour ?

            By the way, what version of Qt are you using ? On what OS ?

            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