How to Create QFileDialog in Qt5 GUI

In this Qt5 article iam going to show How to Create QFileDialog in Qt5 GUI.

 

Check Qt5 C++ GUI Development Articles in the below links

 

1: Qt5 C++ Introduction And Installation

2: Qt5 C++ First Console Application 

3: Qt5 C++ First GUI Application 

4: Qt5 C++ Signal And Slots Introduction

5: Qt5 C++ Layout Management 

6: Qt5 C++ Creating Qt Style Sheets

7: Qt5 C++ Creating QPushButton

8: How To Create QCheckBox in Qt5

9: Qt5 GUI How To Create QRadioButton

10: Qt5 GUI Development How To Create ComboBox

11: Qt5 C++ GUI Development Creating QListWidget

12: Qt5 C++ GUI Development Creating QMessageBox

13 : Qt5 C++ GUI Creating QMenu And QToolbar

14: Qt5 C++ GUI Development Creating QPrintDialog

15: Qt5 C++ GUI Development Creating QFontDialog

16: Qt5 C++ GUI Development Creating QColorDialog

 

 

so the QFileDialog class enables a user to traverse the file system in order to select one or many files or a directory.

the easiest way to create a QFileDialog is to use the static functions.

 

In the above example, a modal QFileDialog is created using a static function. The dialog initially displays the contents of the “/home/jana” directory,

and displays files matching the patterns given in the string “Image Files (*.png *.jpg *.bmp)”. The parent of the file dialog is set to this, and

the window title is set to “Open Image”.

 

 

If you want to use multiple filters, separate each one with two semicolons. For example:

 

 

Also yo can create your own QFileDialog without using the static functions. By calling setFileMode(), you can specify what the user must select in the dialog:

 

 

 

OK now right click on your Open menu item in Signals And Slot Editor, after that choose Go To Slot  and from the dialog choose triggered() like this.

iam using my previous article example How To Create QMenu.

Qt5 QFileDialog
Qt5 QFileDialog

 

 

 

Also open your mainwindow.h and add QPrintDilaog header like this

 

 

After adding your mainwindow.h file will look like this

 

 

Now open your mainwindow.cpp and these codes in the slot

 

 

After adding your mainwindow.cpp will look like this

 

 

 

Run the complete project and this will be the result

How to Create QFileDialog in Qt5 GUI
How to Create QFileDialog in Qt5 GUI

 

 

 

Also you can watch the complete video 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×