(C++) QFileDialogExample2
February 24, 2017 · View on GitHub
(C++) QFileDialogExample2



QFileDialog example 2: using QFileDialog::getOpenFileNames is a QFileDialog example.
- View a screenshot of 'CppQFileDialogExample2' (png)
- Download the Qt Creator project 'CppQFileDialogExample2' (zip)
Technical facts
Operating system(s) or programming environment(s)
Lubuntu 15.04 (vivid)
Qt Creator 3.1.1
- G++ 4.9.2
Libraries used:
Qt project file: ./CppQFileDialogExample2/CppQFileDialogExample2.pro
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets QMAKE_CXXFLAGS += -std=c++11 TEMPLATE = app SOURCES += main.cpp
./CppQFileDialogExample2/main.cpp
#include <iostream> #include <QApplication> #include <QFileDialog> int main(int argc, char *argv[]) { QApplication a(argc, argv); const auto v = QFileDialog::getOpenFileNames(); std::cout << "Number of files selected: " << v.size() << '\n'; for (auto s: v) std::cout << s.toStdString() << '\n'; } /* Example output: Number of files selected: 0 */ /* Example output: Number of files selected: 3 /home/richel/ProjectRichelBilderbeek/Test/build-CppQFileDialogExample2-Qt_5_0_1_qt5-Debug/CppQFileDialogExample2 /home/richel/ProjectRichelBilderbeek/Test/build-CppQFileDialogExample2-Qt_5_0_1_qt5-Debug/main.o /home/richel/ProjectRichelBilderbeek/Test/build-CppQFileDialogExample2-Qt_5_0_1_qt5-Debug/Makefile */