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?
abk file to load it into the address book. void AddressBook::loadFromFile() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Address Book"), "", tr("Address Book (*. abk);;All Files (*)")); On Windows, for example, this function pops up a native file dialog, as shown in the following screenshot.
open(QIODevice::WriteOnly) and then write data to it. Similarly, to get data out of a file, you will need to call file. open(QIODevice::ReadOnly) and then read the data. You can do whatever you want with the data after that.
Use QFileDialog::getOpenFileName
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With