qt6
zcy 2022-01-18 17:12:01 +08:00
parent 58d67597cc
commit 955c57c860
2 changed files with 33 additions and 0 deletions

30
Qss.cpp
View File

@ -1789,8 +1789,38 @@ int QSSASyncProcess::Start(void *p)
return 0; return 0;
} }
QThread &QSSASyncProcess::Thread()
{
return mThread;
}
void QSSASyncProcess::Run(void *) void QSSASyncProcess::Run(void *)
{ {
emit(Done()); 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"<<screenNum<<screens.size();
if(screenNum >= 0){
QScreen* screen = qApp->screens().at(monitor);
dpi = screen->physicalDotsPerInch();
}
qDebug()<<dpi;
int currentScreenWidth = QApplication::desktop()->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;
}

3
Qss.h
View File

@ -122,6 +122,8 @@ public:
QssPushButton(QWidget *parent,QString objName); QssPushButton(QWidget *parent,QString objName);
}; };
// 获取当前dpi
uint16_t CurrentDPI(QWidget* widget,int monitor);
class QssTtitleBar : public QWidget class QssTtitleBar : public QWidget
{ {
@ -500,6 +502,7 @@ public:
QSSASyncProcess(QWidget *parent = nullptr); QSSASyncProcess(QWidget *parent = nullptr);
~QSSASyncProcess(); ~QSSASyncProcess();
int Start(void*); int Start(void*);
QThread &Thread();
signals: signals:
void DonePercent(int); void DonePercent(int);
void Done(); void Done();