Results 1 to 16 of 16

Thread: Any way to properly handle Windows DPI setting?

  1. #1
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Any way to properly handle Windows DPI setting?

    I'm using Qt 4.6.2 open source, my application uses QDialog with font sizes in "pt". I noticed that if I choose 125% scaling factor in Windows, font size increases properly, but dialog window size in pixels remains the same.
    Is there any way to scale widgets according to Windows settings? It would be great if there's been a way to set widget sizes in "pt" instead of pixels.
    Any help is greatly appreciated.
    Last edited by vaddimka; 12th May 2010 at 18:12.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Any way to properly handle Windows DPI setting?

    Are you using layouts?

  3. #3
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to properly handle Windows DPI setting?

    Quote Originally Posted by fatjuicymole View Post
    Are you using layouts?
    No, actually I don't. Even if I was, it would mess up some custom formatting. I'd prefer to scale dialog with constrain proportions, AFAIK layouts can't do that.

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Any way to properly handle Windows DPI setting?

    If you "hard-code" the dimensions of widgets you get that kind of "errors", so use layouts, it's even easier to write and it's more flexible about any changes like: font size or text length.

    What custom formatting? Just try layouts, i'm sure that they will auto-fit your widgets in dialog, just give layouts a chance.
    My advice is: start a small project and try to replicate that formatting with widgets in layouts and see how layouts align stuff in your application.

  5. The following user says thank you to Zlatomir for this useful post:

    zoz (4th June 2010)

  6. #5
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to properly handle Windows DPI setting?

    I'm just afraid I won't be able to replicate this design using layouts.


  7. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Any way to properly handle Windows DPI setting?

    You could probably toss that layout together in Designer in under an hour. If you're new to Designer. I don't see anything remarkable about it that would require custom layout coding.

  8. #7
    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: Any way to properly handle Windows DPI setting?

    What does that screen look like at "125%" or (worse) "150%"? Please upload the image by attaching it here, not to a third party image host where the image can (will) disappear without warning.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Any way to properly handle Windows DPI setting?

    The left part is QFormLayout, the right part is QVBoxLayout with QGridLayout instances holding particular groups and everything can be placed either in a horizontal splitter or in a QHBoxLayout. It's about 10 minutes of work for a skilled engineer to replicate this layout in Designer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to properly handle Windows DPI setting?

    Thank you for the replies. It took me a while to wrap my head around layouts. I finally managed to get it working, but in some cases the problem still remains. Now I have flexible design and if the window has sufficient size everything is perfect (ok, almost everything).

    But still, sometimes minimum size of QCheckBox is calculated incorrectly. Which means it is possible to get something like that when playing with window size:

    (150% increase or 144 DPI)

    I tried to fool around with QSizePolicy (http://doc.trolltech.com/4.6/qsizepo...ml#Policy-enum ) and ended up with nothing, it's either bug or I'm doing something terribly wrong. Tried "Preferred" and "MinimumExpanding" all the way down through the hierarchy, still no luck.

  11. #10
    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: Any way to properly handle Windows DPI setting?

    What do you want to do with the highlighted radio button label? Wrap the text, grow the enclosing panel, something else?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Any way to properly handle Windows DPI setting?

    Is this what you wanted?

    preview1.png
    Attached Files Attached Files
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. The following user says thank you to wysota for this useful post:

    vaddimka (13th May 2010)

  14. #12
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to properly handle Windows DPI setting?

    Quote Originally Posted by wysota View Post
    Is this what you wanted?
    Man, you're a pro! This masterpiece looks perfect even in bloody 200 DPI. Your design is so simple and efficient. It seems I've been overcomplicating things from the very beginning. Thank you very mush for the example you provided, I finally realized how the things should be done.

  15. #13
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to properly handle Windows DPI setting?

    Curious observation: if I only change checkbox text from 'Applications started via Secure Launch' to simple 'A', it breaks the whole thing:

    This is how the example looks in 200 DPI originally:
    ivm_orig..jpg

    This is how it looks after minor modification:
    ivm_changed..jpg

    I'm still thinking it must be some kind of bug in Qt.

  16. #14
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to properly handle Windows DPI setting?

    More on topic!
    The bug disappears if I place labels before checkboxes. Labels can have any name (even be empty). I named them as "." for clearness:
    ivm_changed2..jpg

    Maybe this workaround will come in handy for someone.

  17. The following 2 users say thank you to vaddimka for this useful post:

    ChrisW67 (16th May 2010), zoz (4th June 2010)

  18. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Any way to properly handle Windows DPI setting?

    The form layout seems to be a bit broken in this matter. I think it is worth submitting a bug report.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #16
    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: Any way to properly handle Windows DPI setting?

    I had noticed similar behaviour in one or two of my forms where radio button labels in the right form column were truncated. I hadn't tried placing an empty label in the left column. Thanks
    vaddimka and Wysota.

    I just lodged it as http://bugreports.qt.nokia.com/browse/QTBUG-10726
    Last edited by ChrisW67; 16th May 2010 at 11:15.

  20. The following user says thank you to ChrisW67 for this useful post:

    zoz (4th June 2010)

Similar Threads

  1. Handle windows audio volume
    By Raccoon29 in forum General Programming
    Replies: 7
    Last Post: 6th December 2009, 23:41
  2. How to Handle pop up windows?
    By thewooferbbk in forum Qt Programming
    Replies: 0
    Last Post: 29th November 2009, 04:36
  3. Replies: 0
    Last Post: 4th November 2009, 19:15
  4. Obtaining Windows Handle for Child Process
    By GTBuilder in forum Qt Programming
    Replies: 5
    Last Post: 19th March 2008, 22:54
  5. Windows file handle on QFile?
    By Teerayoot in forum Qt Programming
    Replies: 4
    Last Post: 14th May 2007, 12:11

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.