PDA

View Full Version : Size Policy Scaling Issue



MVivonetto
13th January 2017, 03:13
Hey Guys I might have shot myself in the foot here but I created a QWidget Application that is fully functional and works great but I might have an issue that may require me to completely start over. I built the GUI in the creator and completely customized the layout of all my widgets(PushButtons, GraphicsView, ect.).

What I now would like to accomplish is scaling the application and all of its components when one changes the size of the MainWindow(maximizing to fit the full screen specifically). I realize you can do this with Size Policy but I believe you have to use layouts with your widget components. I didn't use any layouts and custom positioned each widget specifically. Is there any way i can fix this and have them scale to where the full screen will look like the original startup?

I'll include pictures below for better understanding of my problem of what I'm trying to accomplish.



1228612287


I would like my components to scale so it looks like the starting position when its at full screen. Thanks in advance guys and hoping I don't have to start over!

Santosh Reddy
13th January 2017, 07:29
You will have to redo the UI with layouts, but will be simpler than placing the components position manually. Please make you understand Qt layout system and available layout and size policy options, if you understand them it should not be difficult (even for a Qt beginner) redo the UI using layouts. As and hint, for given picture, the central widget (the video player) could be set to minimum expanding and rest buttons can fixed size policy.

MVivonetto
13th January 2017, 15:07
Thank You for the info Santosh I will go ahead and get started...One last question..Will The text on my components scale as well? or do I have to create a function to do that?

Santosh Reddy
16th January 2017, 05:26
Text will not scale. You will need to write a custom logic for text size (changing the text's font size) based on widget's size.

One possibility could be to implement a custom QLabel, where the font size can be changed based on QLabel's size by re-implementing resizeEvent() method. Please note that if size policy is set to fixed in QLabel, then the resizeEvent() may not be of help.

Just serach in forum for "QLabel scale text".

If you want to scale the text in pushbutton or other widgets the approach will be similar.