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.
Re: Any way to properly handle Windows DPI setting?
Re: Any way to properly handle Windows DPI setting?
Quote:
Originally Posted by
fatjuicymole
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.
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.
Re: Any way to properly handle Windows DPI setting?
I'm just afraid I won't be able to replicate this design using layouts.
http://img41.imageshack.us/img41/3472/42532607.th.png
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.
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.
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.
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:
http://www.deviant.ru/trash/ivmshot2.png
(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.
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?
2 Attachment(s)
Re: Any way to properly handle Windows DPI setting?
Is this what you wanted?
Attachment 4625
Re: Any way to properly handle Windows DPI setting?
Quote:
Originally Posted by
wysota
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.
2 Attachment(s)
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:
Attachment 4634
This is how it looks after minor modification:
Attachment 4635
I'm still thinking it must be some kind of bug in Qt.
1 Attachment(s)
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:
Attachment 4636
Maybe this workaround will come in handy for someone.
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.
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