From 6eea8cbbee2f09aca6dcee220a2b79bb38395ed2 Mon Sep 17 00:00:00 2001 From: feiyangqingyun Date: Mon, 27 Dec 2021 09:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- third/third.pro | 1 - ui/flatui/flatui.cpp | 2 +- ui/flatui/flatui.h | 2 +- ui/styledemo/frmmain.cpp | 4 +--- ui/styledemo/frmmain.ui | 40 +++++++++++++++++++++++++--------------- ui/styledemo/main.cpp | 8 ++++++-- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/third/third.pro b/third/third.pro index df7bfb5..d968c73 100644 --- a/third/third.pro +++ b/third/third.pro @@ -17,7 +17,6 @@ greaterThan(QT_MAJOR_VERSION, 5) { SUBDIRS -= hotkey SUBDIRS -= shortcut SUBDIRS -= qwtdemo -SUBDIRS -= qcustomplotdemo } win32 { diff --git a/ui/flatui/flatui.cpp b/ui/flatui/flatui.cpp index 923b3d4..78a76fb 100644 --- a/ui/flatui/flatui.cpp +++ b/ui/flatui/flatui.cpp @@ -53,7 +53,7 @@ QString FlatUI::setProgressQss(QProgressBar *bar, int barHeight, { QStringList list; - list.append(QString("QProgressBar{font:%1pt;background:%2;max-height:%3px;border-radius:%4px;text-align:center;border:1px solid %2;}") + list.append(QString("QProgressBar{font:%1px;background:%2;max-height:%3px;border-radius:%4px;text-align:center;border:1px solid %2;}") .arg(fontSize).arg(normalColor).arg(barHeight).arg(barRadius)); list.append(QString("QProgressBar:chunk{border-radius:%2px;background-color:%1;}") .arg(chunkColor).arg(barRadius)); diff --git a/ui/flatui/flatui.h b/ui/flatui/flatui.h index 5c44910..bfcb64c 100644 --- a/ui/flatui/flatui.h +++ b/ui/flatui/flatui.h @@ -53,7 +53,7 @@ public: static QString setProgressQss(QProgressBar *bar, int barHeight = 8, //进度条高度 int barRadius = 5, //进度条半径 - int fontSize = 9, //文字字号 + int fontSize = 12, //文字字号 const QString &normalColor = "#E8EDF2", //正常颜色 const QString &chunkColor = "#E74C3C"); //进度颜色 diff --git a/ui/styledemo/frmmain.cpp b/ui/styledemo/frmmain.cpp index 9aa4385..71e1fbb 100644 --- a/ui/styledemo/frmmain.cpp +++ b/ui/styledemo/frmmain.cpp @@ -24,9 +24,7 @@ void frmMain::initForm() int rowHeight = 23; ui->tableWidget->horizontalHeader()->setFixedHeight(rowHeight); - for (int i = 0; i < 5; ++i) { - ui->tableWidget->setRowHeight(i, rowHeight); - } + ui->tableWidget->verticalHeader()->setDefaultSectionSize(rowHeight); //加载鼠标右键菜单翻译文件 QTranslator *translator1 = new QTranslator(qApp); diff --git a/ui/styledemo/frmmain.ui b/ui/styledemo/frmmain.ui index a63ec76..0c58d04 100644 --- a/ui/styledemo/frmmain.ui +++ b/ui/styledemo/frmmain.ui @@ -6,8 +6,8 @@ 0 0 - 817 - 616 + 820 + 632 @@ -310,7 +310,7 @@ - 弹出新窗体 + 新窗体 @@ -427,7 +427,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9.07563pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:9.07563pt;"><br /></p></body></html> @@ -545,9 +545,6 @@ p, li { white-space: pre-wrap; } - - true - 20 @@ -563,9 +560,6 @@ p, li { white-space: pre-wrap; } false - - true - 1 @@ -765,7 +759,7 @@ p, li { white-space: pre-wrap; } 0 0 - 817 + 820 26 @@ -892,12 +886,28 @@ p, li { white-space: pre-wrap; } setValue(int) - 369 - 235 + 424 + 265 - 468 - 235 + 547 + 260 + + + + + verticalSlider + valueChanged(int) + progressBar2 + setValue(int) + + + 736 + 101 + + + 760 + 115 diff --git a/ui/styledemo/main.cpp b/ui/styledemo/main.cpp index 2d612dd..390c61b 100644 --- a/ui/styledemo/main.cpp +++ b/ui/styledemo/main.cpp @@ -5,9 +5,13 @@ int main(int argc, char *argv[]) { //设置不应用操作系统设置比如字体 QApplication::setDesktopSettingsAware(false); -#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) - QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor); +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + QApplication::setAttribute(Qt::AA_Use96Dpi); #endif +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor); +#endif + QApplication a(argc, argv); //a.setFont(QFont("Microsoft Yahei", 9)); QFont font;