-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (27 loc) · 960 Bytes
/
main.cpp
File metadata and controls
33 lines (27 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <QApplication>
#include <QFontDatabase>
#include <QIcon>
#include <QScreen>
#include "mainwindow.hpp"
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
int fontId = QFontDatabase::addApplicationFont(":/msyh.ttc");
if (fontId != -1) {
QString fontFamily = QFontDatabase::applicationFontFamilies(fontId).at(0);
QFont font(fontFamily);
app.setFont(font);
} else {
qWarning("Failed to load font.");
}
MainWindow mainWindow;
mainWindow.setWindowTitle(QString("串口调试助手"));
mainWindow.setWindowIcon(QIcon(":/application.png"));
const QRect screenRect = QApplication::primaryScreen()->availableGeometry();
const int screenWidth = screenRect.width();
const int screenHeight = screenRect.height();
const int x = (screenWidth - mainWindow.width()) / 2;
const int y = (screenHeight - mainWindow.height()) / 2;
mainWindow.move(x, y);
mainWindow.show();
return QApplication::exec();
}