Solved Dialog doesn't fill up full space of window on Windows
-
I designed a dialog using Qt Creator 4.14.0 (running Qt 5.15.2) on a macOS 10.15. The dialog consists of a bunch of widgets in a GridLayout and a ButtonBox, with a VerticalLayout applied to the entire dialog box. After applying these layouts, I dragged the bounding boxes for the dialog to be as small as Qt Creator allows me to make them (a height of 369).
When I view this dialog on my Mac, it looks fine, similarly to how it looks on the Qt Creator form. However, when I compile and then view it on a Windows laptop, there's a lot of extra space at the time of the form; it looks just like what Tools->Form Editor->Preview In->Windows Style says it will look like, a screenshot of which is attached (the preview is in the foreground, with the Qt Creator form in the background). I need to re-size the dialog box manually to get it to look right.
I believe the issue is that the dialog opens up to a height of 369 regardless of the platform, and the grid layout on Windows is tighter than it is on Mac, which leads to that empty space. Any tips for how I can make the dialog open up to the minimal height on each platform?
![0_1609808527039_Screen Shot 2021-01-04 at 7.36.33 PM.png](Uploading 100%)
-
@efremdan1 said in Dialog doesn't fill up full space of window on Windows:
However, there appears to be no way to not set the width and height in Designer.
Put your cursor in the geometry value column of the properties panel. Click the "unset" icon that appears in the right hand end of the geometry edit box. On my Linux box this results in the dialog preview assuming a minimal size based on the size hints of the elements in the layout.
-
Here's the screenshot that didn't upload before.
-
Hi,
You are setting a width and a hight in designer so these values will be used no matter the platform. AFAIK, if you do not set these, the widget will get its size from the hints given by its content.
-
Yes, Designer is indeed setting the width and height. If I overwrite the values given by Designer in my own script, e.g., if I say
self.resize(1,1)
after setting up the GUI, then things work.However, there appears to be no way to not set the width and height in Designer. Nor is there a way to set the width and height to values that go below the minimum values on the system I'm designing on (i.e., Designer on my Mac doesn't allow me to bring the height below 369 even that the height is less than that on Windows). I guess I can overwrite that resizing command for each dialog window I create, but that's a very unelegant solution...
Any idea for how to fix this issue in Designer?
-
You can use the sizeHint method to get a value that should suitable.
-
@efremdan1 said in Dialog doesn't fill up full space of window on Windows:
However, there appears to be no way to not set the width and height in Designer.
Put your cursor in the geometry value column of the properties panel. Click the "unset" icon that appears in the right hand end of the geometry edit box. On my Linux box this results in the dialog preview assuming a minimal size based on the size hints of the elements in the layout.
-
@ChrisW67 said in Dialog doesn't fill up full space of window on Windows:
Put your cursor in the geometry value column of the properties panel. Click the "unset" icon that appears in the right hand end of the geometry edit box. On my Linux box this results in the dialog preview assuming a minimal size based on the size hints of the elements in the layout.
The "minimal size" it assumes is dependent on the system in which Qt Creator/Designer is running. On my Mac, clicking that unset icon results in the height going to 369, which is the minimal size on the Mac platform. However, the minimal size on Linux is smaller. So unless I design this dialog on Linux, I won't be able to get that minimal size to appear. Since I'm primarily designing this multi-platform application on my Mac, this doesn't really help.
-
Using the reset arrow will remove the defined size for the widget from the UI file produced by Designer. When UIC processes this at compile time on the Windows platform it cannot be getting the magic 369 pixels from the UI file.
What happens if you apply the grid layout directly to the dialog form rather than nesting it inside a QVBoxLayout?
-
@ChrisW67 said in Dialog doesn't fill up full space of window on Windows:
Using the reset arrow will remove the defined size for the widget from the UI file produced by Designer. When UIC processes this at compile time on the Windows platform it cannot be getting the magic 369 pixels from the UI file.
You are correct. Sorry, I wasn't fully testing your answer. When I saw clicking the reset arrow made the size on Qt Creator 369, I assumed that saving the file would have 369 appear in the UI file in the same manner as if I set the size to 369 in Qt Creator myself. However, the reset arrow actually does remove that number from the UI file. So your solution works.
Thank you!