QWidget is automatically resized beyond maximized



  • 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



  • @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.



  • @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.



  • @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.


  • Lifetime Qt Champion

    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 ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.