How to launch a file browser in a Qt application?

I want to have a button that, when clicked, launches a file browser (like Ctrl + O in Word) and returns the path of the file that user opens.

I know how to make the button, but what should I do in the slot that responds to mouseClicked signal?


Use QFileDialog::getOpenFileName.

What you need to do is write this code in your mouse_click function !

QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open File"),"/path/to/file/",tr("Mp3 Files (*.mp3)"));

*.mp3 will display only mp3 files remove the tr("Mp3 Files (*.mp3)") if you dont want to filter any files

Need Your Help

get city from geocoder results?

google-maps geocoding street-address city

Having problems getting the different arrays content from geocoder results.

How to design an algorithm to calculate countdown style maths number puzzle

java c++ algorithm combinatorics

I have always wanted to do this but every time I start thinking about the problem it blows my mind because of its exponential nature.