×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Adapting Qt app to different screen sizes

    Hi to all!
    I have an application which is aimed to many different devices. Both embedded and non embedded devices. The app already resize its screen geometry based on the device screen size, but now i am stuck with a strange display which have very low resolution (300x200) and very low DPI (screen is quite big).

    What i need to do is tell Qt to "scale" the entire display... to use less DPI in other words.

    One way i was thinking is something like the QPainter.scale() function but applied to entire screen (to widgets too...). Something like chaning viewport for the entire application? So that the output gets automatically scaled to my low-res/low-dpi screen?

    Or is there a way to chnage the DPI application-wide?

    Thank you!

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Adapting Qt app to different screen sizes

    Why cannot you use QLayout and its derivatives?

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Re: Adapting Qt app to different screen sizes

    I already do. But in this specific case i have to go smaller than what the layouts let me go....

    Its not a matter or repositioning controls, its a matter of scaling them down to fit on a low-dpi/low-res screen! I dont care if i loose quality, i need to shrink them all! (i am talking of widgets, if i where drawing them by hand it would be easy inside a paintEvent)

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Adapting Qt app to different screen sizes

    I believe you can manage to make almost all widgets as small as 1x1 pixels. Then they are totally unusable, but this is another thing.

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Re: Adapting Qt app to different screen sizes

    Ok, how i do that?
    At the moment, i force my windows to be "fullscreen", then fit all the widgets with QLayouts. They usually fit, but in case the screen is too small (like this case), what happens is that the window is made larger than the screen and this is not acceptable.

    Is there a way to "force" a window (its actually a widget) to never be larger than the screen, thus forcing its internal layout to squeeze the controls inside even more?

  6. #6
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Adapting Qt app to different screen sizes


  7. #7
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Re: Adapting Qt app to different screen sizes

    I tried, but got nowhere.
    The point is, i can set the SizePolicy on MY widgets, but i cannot set the sizePolicy to ALL the input widgets i use...

    Is there any way i can somehow "scale" the entire screen?

  8. #8
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Adapting Qt app to different screen sizes

    I've found that there are some input widgets it's best to avoid.

  9. #9
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Re: Adapting Qt app to different screen sizes

    Is there a way to obtain the screen DPI within Qt?
    I have substitued almost ALL the input widgets with my widgets, i can make my own "scaling" knowing the screen DPI...

  10. #10
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Adapting Qt app to different screen sizes

    Quote Originally Posted by gardiol View Post
    The point is, i can set the SizePolicy on MY widgets, but i cannot set the sizePolicy to ALL the input widgets i use...
    Could we know a reason of such inability?

    Quote Originally Posted by gardiol View Post
    Is there any way i can somehow "scale" the entire screen?
    It depends on platform and seriosly out of Qt scope. But I guess in your case DPI is hardware limitation, so there is no really way to change it.

  11. #11
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Re: Adapting Qt app to different screen sizes

    Well, for once Qt input widgets do not scale font size, so SizePolicy is useless...
    Besides that, i have hundreds of widgets, manually adding code to fit each one's sizePolicy is not viable... and i do not find it a good solution anyway unless there is no other option, which seems to be the case.

    Anyway, some experiments showed me sizePolicy is NOT the way to go because fonts are still too big. I need to scale the fonts toghether with the widget sizes.
    I guess i have to finish my own set of widgets and throw all Qt input widgets away as they are mostly broken anyway on at least Symbian if not more of the platforms i support.

  12. #12
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Adapting Qt app to different screen sizes

    You don't have to add it for every widget. What you have to do is to get all children of the topmost widget and apply settings to all of them.
    It would be really useful if you name widgets we are talking about. Is it QLabel and QTextEdit with other banal stuff?

  13. #13
    Registered User
    Join Date
    Jul 2010
    Posts
    99

    Re: Adapting Qt app to different screen sizes

    I did not thought about that...

    I am talking about QPushButton, QLabel, QLineEdit, QCheckBox, QComboBox, QListWidget and simial....
    but i guess my main problem is the font size.

    What about chaning the QApplication font size at the beginning of the application? Would this propagate to all widgets?
    That with some icon resizing should fit my needs...

  14. #14
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Adapting Qt app to different screen sizes


Similar Threads

  1. Fonts sizes on different screen sizes
    By TacB0sS in forum Mobile Java General
    Replies: 0
    Last Post: 2010-01-29, 16:00
  2. Porting to different screen sizes, etc
    By ipxlittle in forum Mobile Java General
    Replies: 3
    Last Post: 2009-10-12, 13:33
  3. background for Different screen sizes
    By Bill_Murray in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-06-28, 15:43
  4. How to handle different screen sizes?
    By ykhun in forum Mobile Java General
    Replies: 5
    Last Post: 2005-01-06, 12:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×