PDA

View Full Version : Auto resize GUI depending on screen size



admd91
5th March 2015, 07:58
Hello everyone,

I need to run my app on a 320x240, 3.5 inch screen, preferably maximized with landscape orientation, but I am also anticipating that my app will be used on different screen configurations, so how do I set my GUI to automatically scale correctly to whatever display size that will be used?

I used Qt 4.8.5 to develop my app. My target platform uses ARM (32 bit). also want to confirm if using QWidget::showMaximized will be able to do what I want?

Thanks

ChrisW67
5th March 2015, 08:17
showMaximized() will occupy the entire screen with your widget. The behaviour of the content of your widget, what resizes, what doesn't, where gaps show etc. will be governed by the layout you used.

anda_skoa
5th March 2015, 08:20
That depends on your target system.
If you are running anything with window managing capabilities then yes, showMaximized() or showFullScreen() should do exactly that.

Cheers,
_

admd91
5th March 2015, 08:27
That depends on your target system.
If you are running anything with window managing capabilities then yes, showMaximized() or showFullScreen() should do exactly that.

Cheers,
_


showMaximized() will occupy the entire screen with your widget. The behaviour of the content of your widget, what resizes, what doesn't, where gaps show etc. will be governed by the layout you used.

Thanks for your help ChrisW67 and anda_skoa, I'll try showMaximized() or showFullScreen().

admd91
11th March 2015, 02:14
Hello,

I was just curious about the setFixedSize() method. If, for example, I say for a widget w, would w.setFixedSize(320,240) only show the GUI as landscape?

Thanks

anda_skoa
11th March 2015, 07:41
setFixedSize() sets a fixed size.
It won't resize by itself.

Cheers,
_

admd91
12th March 2015, 02:11
Sorry for asking another question: how do I set my app to run always in landscape orientation, even if the screen it is being displayed on is in portrait? I have tried adding the resizeEvent method from the example here: http://qt-project.org/doc/qt-4.8/widgets-orientation.html, but whenever I start my app on a 3.5 inch display that is in portrait, the app always starts in portrait orientation. How am I to do this?

Thank you for your help,

anda_skoa
12th March 2015, 08:14
Size has nothing to do with orientation.

You'll need to consult the documentation of the system you are working with to see how you can lock an application into one orientation mode.

Cheers,
_

admd91
12th March 2015, 09:04
Size has nothing to do with orientation.

You'll need to consult the documentation of the system you are working with to see how you can lock an application into one orientation mode.

Cheers,
_

Hello anda_skoa and thank you for your reply. So if my understanding is correct, there are no methods in Qt to set the orientation of the app, and the orientation depends on the hardware of the target system?

Thanks again

anda_skoa
12th March 2015, 10:25
Right, this is very platform specific.
Qt5 has methods to determine the orientation, but I think setting is still done through platform API or manifest file

Cheers,
_

admd91
13th March 2015, 10:16
OK thank you for your help!