How to keep the source in Qt5 when DPI increases

Asked

Viewed 30 times

0

I am having problems when I pass my UI to a user who has a visual windows configuration different from mine. If the user display is at 125 or 150% my UI gets huge fonts in the Labels while the other widgets are default. I wanted to keep the Abels' source fixed.

I’ve tried to:

QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

ja setei DPI stay in 96 and nothing.

I tried using a . config

[Platforms]
WindowsArguments = dpiawareness=0 , 1 ou 2

and I tried to set a variable in the project settings but none of it worked, there is some way to make these settings work?

the font configuration I use is the standard of Qt5 Designer.

inserir a descrição da imagem aqui

my main.cpp of the code is as follows:

#include "meu_UI.h"
#include <QtWidgets/QApplication>
#include <QApplication>


int main(int argc, char *argv[])
{
    //QApplication::setAttribute(Qt::AA_Use96Dpi);
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication a(argc, argv);

    meu_UI w;

    w.show();


    return a.exec();
}
  • First thing: Are you setting fonts in pixels or points? The Qt allows the 2 forms, setPixelSize and setPointSize, you should use a fixed pattern (points are usually better to accommodate these situations, but each case is a case). The best would be you [Dit] your post with a [Mcve] demonstrating the problem.

  • I use size but seems not to be affected by settings.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.