diff --git a/mainwindow.cpp b/mainwindow.cpp index d6e2882..69a8d9e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -60,6 +60,7 @@ void MainWindow::on_pushButton_clicked() { QString ext[] = {"png", "jpeg", "jpg"}; + QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); if (fileName.isEmpty()) return; QFile file(fileName); @@ -93,3 +94,18 @@ void MainWindow::on_pushButton_clicked() } + +void MainWindow::on_actionOpen_triggered() +{ + + QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); + if(fileName.isEmpty()) return; + QFile file(fileName); + if(!file.open(QIODevice::ReadOnly | QFile::Text)) { + QMessageBox::warning(this, "Warning", "Fichier non valide" + file.errorString()); + return; + } + + +} + diff --git a/mainwindow.h b/mainwindow.h index 1146f46..38e219a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -29,6 +29,8 @@ public: private slots: void on_pushButton_clicked(); + void on_actionOpen_triggered(); + private: Ui::MainWindow *ui; QString currentFile; diff --git a/mainwindow.ui b/mainwindow.ui index bd25946..8c3b28b 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -319,6 +319,7 @@ false + @@ -465,6 +466,17 @@ QAction::MenuRole::NoRole + + + + + + New + + + QAction::MenuRole::NoRole + +