forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQtMultiFileDialog.C
More file actions
68 lines (65 loc) · 2.24 KB
/
QtMultiFileDialog.C
File metadata and controls
68 lines (65 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/// \file
/// \ingroup tutorial_gui
/// This is a small ROOT macro to use Qt 3.3 class :[QFileDialog](https://doc.qt.io/archives/3.3/qfiledialog.html)
/// See: [https://doc.qt.io/archives/3.3/qfiledialog.html#getOpenFileNames](https://doc.qt.io/archives/3.3/qfiledialog.html#getOpenFileNames)
///
/// To use, invoke ACLiC from the ROOT prompt:
/// ~~~
/// root [] .x QtMultiFileDialog.C++
/// ~~~
///
/// To use it with no ACLiC, omit the trailing "++"
/// ~~~
/// root [] .x QtMultiFileDialog.C
/// ~~~
///
/// The QtMultiFileDialog creates TList of TObjString objects and
/// returns its pointer.
///
/// The "QtFileDialog.C" macro provides the simplified version of the "QtMultiFileDialog.C"
///
/// Option: you can change the look and feel of the Qt file dialog
/// by providing the optional parameter "style":
/// The number of the available styles is defined by your local
/// Qt installation.
/// Try: "windows", "motif", "kde", "platinum" etc
///
/// The full list of the Qt classes available from Cint is defined by
/// [by $ROOTSYS/cint/lib/qtclasses.h](http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html)
///
/// All Qt classes can be used from ACLiC though.
///
/// \macro_code
///
/// \author Valeri Fine 23/03/2006
# include <QApplication>
# include <QStyle>
# include <QFileDialog>
# include <QStringList>
# include <QString>
# include "TObjString.h"
# include "TList.h"
# include <string>
TList *QtMultiFileDialog(const char *style="") {
QStyle *saveStyle = 0;
if (!QString(style).isEmpty()) {
saveStyle = QApplication::style();
QApplication::setStyle(style);
}
TList *listOfNames = new TList();
QStringList files = QFileDialog::getOpenFileNames ();
QStringList::Iterator it = files.begin();
while ( it != files.end() ) {
std::string flnm = (*it).toStdString();
printf ("Next file selected: %s\n", flnm.c_str() );
// Convert QString to TObjString and add it to the output
listOfNames->Add(new TObjString(flnm.c_str()));
++it;
}
// Restore the style
if (saveStyle) QApplication::setStyle(saveStyle);
printf ("\nThe TList of the file names contains:");
printf ("\n-------------------------------------\n");
listOfNames->ls();
return listOfNames;
}