Create open btn
This commit is contained in:
parent
332fa2bc0b
commit
81b4209118
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@ public:
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_actionOpen_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QString currentFile;
|
||||
|
||||
@ -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/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user