I'm trying to make a window adjust to it's optimal size and need to do so quite often. The window is able to dock along the edges of all the screens attached to the computer but when I move to a narrow screen, the window has it's width reduced to 2/3 of the screen's width; as per the documentation.
I can't calculate the size of the window, on my own, beforehand and have to rely on Qt doing the right thing.
I have fairly limited options regarding refactoring (as in pretty much none).
The correct version is from a screen that's 2560 pixels wide.
The narrow version is from when the window is placed on a screen that's 1080 pixel wide.
As you can see, three of the icons are missing in the narrow version.
The size of the window is not some fraction of the screen. It has to be exactly big enough to contain it's content; no more nor less. The problem is not setting the size of the window as such: it's making sure that the size does not adjust itself to narrow screens when adjustSize
is called.