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 ext[] = {"png", "jpeg", "jpg"};
|
||||||
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
|
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
|
||||||
if (fileName.isEmpty()) return;
|
if (fileName.isEmpty()) return;
|
||||||
QFile file(fileName);
|
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:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QString currentFile;
|
QString currentFile;
|
||||||
|
|||||||
@ -319,6 +319,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<addaction name="actionNewFile"/>
|
<addaction name="actionNewFile"/>
|
||||||
|
<addaction name="actionNew"/>
|
||||||
<addaction name="actionSaveFile"/>
|
<addaction name="actionSaveFile"/>
|
||||||
<addaction name="actionSaveAsFile"/>
|
<addaction name="actionSaveAsFile"/>
|
||||||
<addaction name="actionPrintFile"/>
|
<addaction name="actionPrintFile"/>
|
||||||
@ -465,6 +466,17 @@
|
|||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user