4 Star 47 Fork 26

Vanishi/SRE

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mainwindow.cpp 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
#include "mainwindow.h"
#include <QApplication>
#include <QCoreApplication>
#include <QScreen>
#include <QResizeEvent>
#include "SingletonUtils.h"
#include "IndexWidget.h"
#include <QDebug>
#include <QsLog.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setAttribute(Qt::WA_StyledBackground,true);
setStyleSheet(QString(".MainWindow{background-color:%1;}").arg("rgb(31,33,42)"));
QString title = QString("SRE V%1 (64-bit,windows)").arg(QCoreApplication::applicationVersion());
setWindowTitle(title);
QList<QScreen *> screens = QGuiApplication::screens();//获取多屏幕
// QScreen * screen = QGuiApplication::primaryScreen();//获取主屏幕
QScreen * screen = screens.at(0);//获取多屏幕第一块屏幕(暂未做多屏幕的兼容)
QRect screenRect = screen->geometry();
int screenWidth = screenRect.width();
int screenHeight = screenRect.height();
SingletonUtils::getInstance()->setScreenSize(screenWidth,screenHeight);
int w = int(float(screenWidth) * 0.5);
int h = int(float(screenHeight) * 0.5);
QLOG_INFO() << "screens="<<screens.size()<<",screenWidth="<<screenWidth<<",screenHeight="<<screenHeight<<",w="<<w<<",h="<<h;
qDebug() << "screens="<<screens.size()<<",screenWidth="<<screenWidth<<",screenHeight="<<screenHeight<<",w="<<w<<",h="<<h;
this->resize(w,h);
IndexWidget *index = new IndexWidget(this);
setCentralWidget(index);
}
void MainWindow::resizeEvent(QResizeEvent* event){
// qDebug()<<"MainWindow::resizeEvent "<<event->size();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/Vanishi/SRE.git
git@gitee.com:Vanishi/SRE.git
Vanishi
SRE
SRE
master

搜索帮助