-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
39 lines (30 loc) · 867 Bytes
/
Copy pathmainwindow.cpp
File metadata and controls
39 lines (30 loc) · 867 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
34
35
36
37
38
39
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "filebrowserdialog.h"
#include <QDir>
#include <QMessageBox>
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->actionOpenFile, &QAction::triggered, this, &MainWindow::onOpenFile);
connect(ui->actionAboutQt, &QAction::triggered, this, &MainWindow::onAboutQt);
fileDialogPath = QDir::homePath();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onOpenFile()
{
FileBrowserDialog fd(fileDialogPath, this);
int result = fd.exec();
ui->textEdit->append(QString("File dialog result = %1").arg(result));
if (result != 0) {
ui->textEdit->append(QString("Selected file name: \"%1\"").arg(fd.selectedFile()));
}
}
void MainWindow::onAboutQt() {
QMessageBox::aboutQt(this);
}