I've designed an app with a display screen size of 100% (In Windows 7 OS). But now I realize when magnifying the screen to 125%, all the labels in my app are also scaled and clipped/cut off from the screen. I don't want the app (and its widgets like Qlabel) to change its size if Windows magnification is increased.
I tried the following:
I tried running the app with
-platform windows: dpiawareness = 0
Tried setting the follwoing in the main.cpp
QApplication :: setAttribute ( Qt::AA_DisableHighDpiScaling);
However, none of them seems to work.
Why this is happening? Is there any other easy workaround to this issue?
Thanks in advance
Related
I am working on a existing Qt application and trying to support it on 4K monitor. For scaling the app, I am using "QT_SCREEN_SCALE_FACTOR" and scaling fonts based on logical DPI of screen. Everything is fine till this. Fonts for ribbon, docked windows are ok after scaling. But the font is getting too bigger for floating forms (pop up dialogs) and the docked widgets after undocking (the moment window is undocked, font is becoming bigger). I don't understand why this is happening. Is windows taking control over floating forms and making font bigger? Or am I missing something?
I am not using "Qt::AA_EnableHighDpiScaling" or "QT_SCALE_FACTOR" because I did not find these useful for me.
Has anyone faced this kind of problem?
Please let me know if someone knows about this.
After trying this and that, I found a solution to this problem.
I added'QGuiApplication::setAttribute(Qt::AA_DisableHighDpiScaling);' before creating QApp. And then I just needed to change the font size.
Mojave (macOS 10.14) is great.
Xcode 10.0 (10A254a) is great.
Dark Mode is great.
What is not so great, unless I'm missing something, is this ugly gray background of the iOS simulator window (when in full screen):
Any idea on how to change that color?
If anybody still struggles with this here is somewhat a solution: toggle "Show Device Bezels" in the window menu of the simulator will do the trick. However this needs to be done each time the simulator is started....
I have the answer you seek.
Boot into recovery mode (Cmd+R while booting) and then open the Terminal.
cd /Volumes/Macintosh\ HD //if your drive is named something different, replace accordingly
csrutil disable //disables System Integrity Protection
mkdir AppleInternal //activates testing and custom commands in Apple apps, including Simulator
csrutil enable //re-enable System Integrity Protection
reboot //back to regular environment
Now there's an "Internal" menu in the Simulator. In here, you can change loads of settings including the window's background color. It uses the regular OS X colour picker so you can even choose a hex code.
The correct answer to this (I'm on Catalina 10.15.7): Change your desktop background to the desired color. The simulator adapts to the color with a different opacity (or alpha?!) value when in fullscreen mode.
I'm writing a Qt application that needs to run on high-dpi Windows (192dpi instead of 96dpi).
Unfortunately the Qt framework does not have support for high-dpi yet (at least on Windows), so my application and all its elements looks half the size it should.
Is there any way to force/simulate automatic upscaling of such apps by Windows?
Applications that use fixed coordinates and sizes will look small on high-DPI resolutions. Although even if using layouts there are some issues regarding element and font sizes and margins. Fortunately there is support for high-DPI displays since Qt 5.4 as there has been many high-DPI issue fixes.
An application on Windows can assume one of the following levels of "DPI Awareness" (From the Qt documentation) :
DPI Unaware: This level has been introduced in Windows-Vista. Windows will pretend to the application that it is running on a
standard display of 96 DPI of 1920x1080 and scale the application
accordingly. It is intended to accommodate older applications designed
for low DPI displays. Some artifacts may result from this type of
scaling.
System-DPI Aware: This level has been introduced in Windows-Vista. It differs from Per-Monitor DPI Aware only when multiple monitors are
connected. Windows will calculate a scaling suitable for all connected
monitors.
Per-Monitor DPI Aware: This level has been introduced in Windows 8.1. Windows does not perform any scaling at all.
Also it states that :
Qt applications by default are Per-Monitor DPI Aware on Windows 8.1 or
System-DPI Aware on older versions of Windows. As of Qt 5.4, the level
can be specified by passing a parameter to the platform plugin (see
Using qt.conf):
<application> -platform windows:dpiawareness=0,1,2
You can read more information here.
In general to have a good UI on high-DPI displays, consider the following :
Use the latest version of Qt
Use layouts and avoid fixed sizes (unless you calculate scaling ratios on your own)
Make appropriate DPI-related settings depending on your application needs, for example set Qt::AA_UseHighDpiPixmaps attribute if you work with QPainter and pixmaps, or calculate a scaling ratio for adjusting certain element sizes in special situations.
Qt fully supports high DPI monitors from Qt 5.6 onward, via attribute or environment variable (except on OS X where support is native). For the attribute method, use:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QApplication app(argc, argv);
return app.exec();
}
or set the system environment variable:
QT_AUTO_SCREEN_SCALE_FACTOR=1
I've tested both methods on windows 10 with a high-DPI surfacebook monitor and the results are scaled properly as expected.
Here is the quickest way to get the issue solved on Windows.
Next to the executable, create a qt.conf file (if not already there) and add the following:
[Platforms]
WindowsArguments = dpiawareness=0
The window will appear blurry when scaled up. The big advantage of this solution is that Windows does the scaling, not Qt. Therefore the occurence of artifacts is minimized. Furthermore, this can apply to an already-distributed app as it does not require a rebuild.
Of course, this is not the most pleasant result but the quickest to get you out of trouble in short term, letting you develop the "real" DPI-aware version without pressure.
I' am using Qt 4.8. First, you should use layouts. My goal was to prevent user to resize dialogs, forms etc. too.
I achieved correct display results on different DPI by put this code in dialog constructor:
adjustSize();
setFixedSize(size());
First line adjustSize() adjust size of dialog to fit its content.
Second line setFixedSize(size()) fixes size of dialog after adjusting its size to content and prevent users to resize it. You haven't to set size policies.
I' am using Qt 4.8.7. This is my code.
static float dpiX = (float)0;
inline int autoDpiSize(int inSize)
{
if (dpiX == (float)0)
{
HDC screen = GetDC(0);
dpiX = static_cast<float >(GetDeviceCaps(screen, LOGPIXELSX)) / 96.0;
ReleaseDC(0, screen);
}
return dpiX * inSize;
}
someWidget->setFixedHeight(autoDpiSize(30));
I have a weird issue with QT Creator. The soft is opening in full screen.
It is annoying because I don't have the bar with File, Edit, Tools etc...
How to disable this fullscreen mode ?
Thanks
You can switch between fullscreen and window mode using Ctrl+Shift+F11. Still, it's strange that the menus aren't visible, normally they are retained even in full screen mode.
I'm using a PiTFT on my pi and running a JavaFX program. I got the output going to the PiTFT by running fbcp in the background.
I had to set disable_overscan=1 in /boot/config.txt to get it to show the whole image. That all works fine now.
My problem is that the touch screen calibration doesn't seem to effect JavaFX apps. The X and Y axis are swapped. Does anybody know how to calibrate the touch screen for JavaFX apps?
I don't know if this is a problem with the touchscreen driver for the PiTFT or a JavaFX configuration problem, so I'm going to post the same question to the adafruit forums and if I get an answer in one place, I'll copy it to the other.
I've struggled with the same problem today, and I managed to figure it out.
The PiTFT is by default a portrait display with a resolution of 240x320. The driver conf is originally made to rotate the display. The touchscreen setting for X are aware of that and have the rotate option set accordingly. And yes, this will not affect JavaFX since it doesn't run in X.
What I did:
in /boot/config.txt
disable_overscan=1
framebuffer_width=480
framebuffer_height=640
#set specific CVT mode
hdmi_cvt 480 640 60 1 0 0 0
#set CVT as default
hdmi_group=2
hdmi_mode=87
hdmi_force_hotplug=1
With this, the main display resolution is set to 480x640, and overscan is disabled.
Next, in /etc/modprobe.d/adafruit.conf, change the rotate option to be 0.
Save everything and reboot. Then fbcp & java Main, and it should be working OK.
Btw, be aware that I used the pre-built raspbian image from adafruit.