Example of standard Qt dialogs: Open file

I am starting to learn Qt for use in one of my projects, and I need to create a graphical interface that allows the user to open the file. I was looking through examples, and I found that one of them has what I need; the problem is that he also has many other things, to the extent that I have no idea what I'm looking at or what I'm looking for.

Basically, my question is this:

How to do what you can see below in the image where, after clicking the button and selecting the corresponding file, it is displayed and saves the file path in the field on the right? enter image description here

I already understood how to make the button open a dialog with a file, my only problem is to make it store and display the file path.

+6
source share
1 answer

Solved this using this:

void OpenXMLFile::on_File1Button_clicked() { file1Name = QFileDialog::getOpenFileName(this, tr("Open XML File 1"), "/home", tr("XML Files (*.xml)")); ui->File1Path->setText(file1Name); } void OpenXMLFile::on_File2Button_clicked() { file2Name = QFileDialog::getOpenFileName(this, tr("Open XML File 2"), "/home", tr("XML Files (*.xml)")); ui->File2Path->setText(file2Name); } 

Where is my GUI:

enter image description here

(The boxes next to the buttons are Line Editing if anyone was wondering)

+12
source

All Articles