Getting position of window with font increase - qt

i have a problem with getting position of qt window in Windows while i have text size increased in windows settings.
So i'm developing an Qt app for multimonitor setup, the app monitors it's position and returns to screen to which is associated.
I already tried to get window position with:
1.Qt function geometry()
2.Qt function frameGeometry()
3.Inside Qt window calss this->pos()
4.WinApi function GetWindowRect
All of them work fine when font size in Windows settings is set to 100%.
But when i change font size to 125% and more only on the main midle screenn, position returned by that functions are wierd, too big something like from -6800 to 6000 in pixels with font size 175%, when i have 3 monitors 1920x1080 in row from -1920 to 1920(rightest screen position) and 3840 rightest pixel column.
CCD Api returns me that i still have from -1920 to 1920 with font size increased. and so says registry in
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\UnitedVideo\CONTROL\VIDEO\
So the question is, how to get window position when font is incresed ?
And who is wrong here me, doing wrong thing or Windows have a bug?

Related

Whats the proper way for scaling text?

I am developing a Qt QML based application that runs on both Desktop and Mobile operating systems. I am having problems with proper fonts and components scaling- what does look good on large, desktop monitor is barely visible on a mobile phone, even though the scaling is the same.
I was wondering, what is the proper approach for this problem? I would like to run the same code on all platforms. For example, is there a way for a font to stay the same size (in mm or inches), no matter the screen resolution and size?
In QML I am always setting the font.pointSize property. It is scaled evenly, but because of that, the font are barely visible on mobile devices.
Have you tried font.pixelSize property yet?
I think this will be good for you.
"Sets the font size in pixels.
Using this function makes the font device dependent. Use pointSize to set the size of the font in a device independent manner."
https://doc.qt.io/qt-5/qml-qtquick-text.html#font.pixelSize-prop

Running Pyautogui on a different computer with different resolution

I have a python script which runs perfectly on my work computer (1600 x 900 resolution). It is on this computer that I took all the screenshot images used by pyautogui.locateOnScreen. I tried to run this program on my home laptop with a different resolution (1340 x 640) and the script does not seem to find the image location. I am guessing that it is because of the different resolution. (I have copied the script folder from my work computer to the home computer, so the path to the image file is exactly the same). Is there anything I can change in my script so that pyautogui.locateOnScreen would identify the image on any computer resolution?
I'm the creator of PyAutoGUI. The problem you have isn't with the screen resolution, but the screen scaling. Your program will work fine on monitors at different resolutions. But at high resolutions, the text and buttons of your programs become too small and so Windows and macOS fix this with "screen scaling", which can increase the size of UI elements like text and buttons by 150% or 200%. If you have multiple monitors, each monitor can have it's own screen scaling setting; for example one monitor at 100% and another at 150%.
If you take a screenshot while a monitor is at, for example, 100% and then try to use it on a monitor that is scaled at 200%, the image won't match because the screenshot is literally half the width and length of what it would have been on the 200% monitor.
So far, there is no work around for this. Resizing the screenshot might not work because there could be subtle differences and the screenshot mechanism currently needs a pixel-perfect match. You just need to retake the screenshots on the monitor with the different screen scaling setting.
I think you'll need to take a screenshot of the image on the different resolution, and at the start of your program have it detect whether it's on the 1600x900 screen or the 1340x640 screen. Then make all the 'locateOnScreen' pieces take a variable, and depending on the screen size, replace those variables with the path to the correct image.
import pyautogui
def function():
pyautogui.locateOnScreen(x)
...
pyautogui.locateOnScreen(y)
...
screen = pyautogui.size()
if screen = (1600, 900):
x = 'image1_1600_900.png'
y = 'image2_1600_900.png'
else:
x = 'image1_1340_640.png'
y = 'image2_1340_640.png'
function()

Using high DPI images with QtStyleSheet

I have a Qt Widgets application using Qt styleSheet for the app look and feel. We want to add support for high-DPI displays, as on these, the app looks very small. The first step was thus to call:
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
This does most of the job and the app window is big enough. The only remaining issue is the resolution of the images used in style sheet.
Say that we have:
QCheckBox::indicator::unchecked {
image: url(:/res/checkbox_off.png);
}
MainWindow QFrame {
background-image: url(:/res/background.png);
}
When using high DPI scaling, these images get upscaled accordingly which is a problem. For high DPI, I would prefer to use higher resolution images to make them look as crisp as possible.
As expected, a naive approach of simply providing the images in higher resolution does not work - it makes images and controls twice as large (on both low and high DPI screens).
Qt documentation on QImageReader states that
The high resolution version is marked by the suffix #2x on the base name. The image read will have its device pixel ratio set to a value of 2.
However, I have provided these resources with twice the resolution, added them to qrc file, but the images displayed are still the same on device with pixel_ratio of 3.
Are there any other steps needed to make this automatic image loading work with stylesheets?

Unity Canvas Buttons gets tiny when Build

I am working with Unity 5, and when I add Canvas Button the button get smaller
this is how it looks like before build
Before Build to an Apk
and after build on my Lg g3:
As seen on your screenshots, the button has a fixed size in pixels. and your mobile screen probably has a higher screen resolution.
Set the Canvas Scaler to something other than
Constant Pixel Size as this Makes UI elements retain the same size in pixels regardless of screen size.
scale with screensize would in this case be more fitting. As it Makes UI elements bigger the bigger the screen is.
as per Unity Documentation

Consistent touch target size on High DPI mobile device ? (WebApp scenario)

Considering a css pixel is not a device pixel on high DPI device, predict and manage touch target size across these devices have been a headache for me.
For example, say I have a Web App with viewport meta "width=device-width, initial-scale=1.0", on iPad (9.7 inch screen) in landscape mode, viewport is set to 1024px, and 50px (in css) is roughly 1cm in physical size.
However for device such as Nexus 7 (7 inch screen), viewport would be set to 966px, thus 50px (in css) is only about 0.7cm in physical size. (Not to mention a growing list of High DPI device that I may not get my hands on)
Different guideline varies on recommeneded touch target size, but I tend to prefer around 1cm to allow for human error.
Is there a best practice for such scenario? the idea described in Let's Get Physical (Units) is the closest I found via google, but far from production ready.
Start using em or percentages instead of px.
This is probably going to be what pushes everyone over the line.

Resources