Create open btn

This commit is contained in:
T'JAMPENS QUENTIN p2406187 2025-06-19 09:35:28 +02:00
parent 332fa2bc0b
commit 81b4209118
3 changed files with 30 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -29,6 +29,8 @@ public:
private slots:
void on_pushButton_clicked();
void on_actionOpen_triggered();
private:
Ui::MainWindow *ui;
QString currentFile;

View File

@ -319,6 +319,7 @@
<bool>false</bool>
</attribute>
<addaction name="actionNewFile"/>
<addaction name="actionNew"/>
<addaction name="actionSaveFile"/>
<addaction name="actionSaveAsFile"/>
<addaction name="actionPrintFile"/>
@ -465,6 +466,17 @@
<enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
<action name="actionNew">
<property name="icon">
<iconset theme="QIcon::ThemeIcon::DocumentOpen"/>
</property>
<property name="text">
<string>New</string>
</property>
<property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
</widget>
<resources/>
<connections/>