From 60b379268d6acacba905b6df0c575b659424ae6c Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Thu, 15 Jan 2026 13:27:52 +0800 Subject: [PATCH] fix: blurry icons and images when build with Qt 5 This fix the issue that the icons on sidebar and the mascot on about dialog is blurry. --- src/main.cpp | 3 +++ src/widgets/common/customlabel.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 2da9621..273c431 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -180,6 +180,9 @@ int main(int argc, char *argv[]) } int fakeArgc = argc + 2; // QCoreApplication 的 argc 要用引用,避免 c++ 编译器优化 Application a(fakeArgc, fakeArgs.data()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + a.setAttribute(Qt::ApplicationAttribute::AA_UseHighDpiPixmaps); +#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // 设置版本和构建时间 a.setBuildDateTime(buildDateTime); diff --git a/src/widgets/common/customlabel.cpp b/src/widgets/common/customlabel.cpp index 27b940e..4c9e51e 100644 --- a/src/widgets/common/customlabel.cpp +++ b/src/widgets/common/customlabel.cpp @@ -10,7 +10,11 @@ CustomLabel::CustomLabel(QWidget *parent, QPixmap CustomLabel::pixmap() const { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) return *QLabel::pixmap(); +#else + return QLabel::pixmap(); +#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) } void CustomLabel::setPixmap(const QPixmap &pixmap)