-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
44 lines (32 loc) · 1.05 KB
/
mainwindow.cpp
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
34
35
36
37
38
39
40
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this); //如果ui和oglmanager的生成顺序相反,会失去manager的鼠标焦点,鼠标操作无效化
oglManager = new XOpenGLWidget(this);
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MainWindow::updateOGL);
timer->start(10);
/******** 设置背景颜色 ***********/
QPalette pal(this->palette());
pal.setColor(QPalette::Background, QColor(99, 103, 106));
this->setAutoFillBackground(true);
this->setPalette(pal);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::keyPressEvent(QKeyEvent *event){
oglManager->handleKeyPressEvent(event);
}
void MainWindow::keyReleaseEvent(QKeyEvent *event){
oglManager->handleKeyReleaseEvent(event);
}
void MainWindow::on_pushButton3_clicked(){
QString fileName = QFileDialog::getOpenFileName(this, tr("Select File"), ".");
qDebug() << fileName;
oglManager->changeObjModel(fileName);
}