mirror of https://gitee.com/cxasm/notepad--.git
support high dpi
This commit is contained in:
parent
ea55d37104
commit
7ea8d7a5ba
21
src/main.cpp
21
src/main.cpp
|
@ -120,11 +120,18 @@ class MyApplication : public QApplication
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//可以防止某些屏幕下的字体拥挤重叠问题。暂时屏蔽,不使用qt方法,使用windows自带方案
|
||||
// 发现windows自带方案模糊。//发现下面打开后,在win10上反而效果不好,界面会变得很大,默认还是不开启的好。
|
||||
//QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
//QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
//QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
#ifdef Q_OS_WIN
|
||||
HDC hdc = CreateDC(L"display", NULL, NULL, NULL);
|
||||
int ndpi = GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
qputenv("QT_SCALE_FACTOR", QString::number(ndpi / 96.0).toUtf8());
|
||||
#endif // Q_OS_WIN
|
||||
#endif
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
MyApplication a(argc, argv);
|
||||
|
@ -132,6 +139,10 @@ int main(int argc, char *argv[])
|
|||
QApplication a(argc, argv);
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
//不能开启,开启后相对路径打开文件失败
|
||||
//QDir::setCurrent(QCoreApplication::applicationDirPath());
|
||||
|
||||
|
|
Loading…
Reference in New Issue