diff --git a/Qss.cpp b/Qss.cpp index db255b3..f05c7cc 100644 --- a/Qss.cpp +++ b/Qss.cpp @@ -1789,8 +1789,38 @@ int QSSASyncProcess::Start(void *p) return 0; } +QThread &QSSASyncProcess::Thread() +{ + return mThread; +} + void QSSASyncProcess::Run(void *) { emit(Done()); } + +uint16_t CurrentDPI(QWidget* widget,int monitor) +{ + float dpi = 1.0; + int screenNum = qApp->desktop()->screenNumber(widget); //this 表示当前的窗口 QWidget类型 + auto screens = qApp->screens(); + qDebug()<<"screenNum"<= 0){ + QScreen* screen = qApp->screens().at(monitor); + dpi = screen->physicalDotsPerInch(); + } + qDebug()<width(); + int currentScreenHeight = QApplication::desktop()->height(); +//或者 + QDesktopWidget* desktopWidget = QApplication::desktop(); + //获取可用桌面大小 + QRect deskRect = desktopWidget->availableGeometry(); + //获取设备屏幕大小 + QRect screenRect = desktopWidget->screenGeometry(); + auto screenX = screenRect.width(); + auto screenY = screenRect.height(); + return dpi; +} diff --git a/Qss.h b/Qss.h index 71c8a59..9c9e748 100644 --- a/Qss.h +++ b/Qss.h @@ -122,6 +122,8 @@ public: QssPushButton(QWidget *parent,QString objName); }; +// 获取当前dpi +uint16_t CurrentDPI(QWidget* widget,int monitor); class QssTtitleBar : public QWidget { @@ -500,6 +502,7 @@ public: QSSASyncProcess(QWidget *parent = nullptr); ~QSSASyncProcess(); int Start(void*); + QThread &Thread(); signals: void DonePercent(int); void Done();