Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) QFileDialogExample2

 

QtQt CreatorLubuntu

 

QFileDialog example 2: using QFileDialog::getOpenFileNames is a QFileDialog example.

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

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
*/

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml