Results 1 to 11 of 11

Thread: Auto resize GUI depending on screen size

  1. #1
    Join Date
    Mar 2015
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Auto resize GUI depending on screen size

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Auto resize GUI depending on screen size

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Auto resize GUI depending on screen size

    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,
    _

  4. #4
    Join Date
    Mar 2015
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Auto resize GUI depending on screen size

    Quote Originally Posted by anda_skoa View Post
    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,
    _
    Quote Originally Posted by ChrisW67 View Post
    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().

  5. #5
    Join Date
    Mar 2015
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Auto resize GUI depending on screen size

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Auto resize GUI depending on screen size

    setFixedSize() sets a fixed size.
    It won't resize by itself.

    Cheers,
    _

  7. #7
    Join Date
    Mar 2015
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Auto resize GUI depending on screen size

    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/wid...ientation.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,

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Auto resize GUI depending on screen size

    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,
    _

  9. #9
    Join Date
    Mar 2015
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Auto resize GUI depending on screen size

    Quote Originally Posted by anda_skoa View Post
    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

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Auto resize GUI depending on screen size

    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,
    _

  11. The following user says thank you to anda_skoa for this useful post:

    admd91 (13th March 2015)

  12. #11
    Join Date
    Mar 2015
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Auto resize GUI depending on screen size

    OK thank you for your help!

Similar Threads

  1. Expand all widgets depending on screen geometry
    By Henry Blue Heeler in forum Qt Programming
    Replies: 3
    Last Post: 8th August 2014, 20:03
  2. Replies: 1
    Last Post: 29th December 2013, 19:06
  3. Replies: 1
    Last Post: 5th September 2013, 17:33
  4. Replies: 2
    Last Post: 11th April 2011, 17:03
  5. resizing widgets depending on a main widget size
    By luf in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2009, 17:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.