Results 1 to 4 of 4

Thread: Size Policy Scaling Issue

  1. #1
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Size Policy Scaling Issue

    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.



    Maximized Size.jpgStartSize.jpg


    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!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Size Policy Scaling Issue

    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.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    MVivonetto (13th January 2017)

  4. #3
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Size Policy Scaling Issue

    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?

  5. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Size Policy Scaling Issue

    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.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. QMainWindow size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2011, 09:34
  2. QDockWidget size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2011, 16:08
  3. Keep aspect size policy?
    By brcain in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2009, 17:18
  4. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  5. QMenuBar size policy
    By krivenok in forum Qt Programming
    Replies: 3
    Last Post: 16th January 2006, 15:13

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.