ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
gui
QtMultiFileDialog.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This is a small ROOT macro to use Qt 3.3 class :[QFileDialog](https://doc.qt.io/archives/3.3/qfiledialog.html)
4
/// See: [https://doc.qt.io/archives/3.3/qfiledialog.html#getOpenFileNames](https://doc.qt.io/archives/3.3/qfiledialog.html#getOpenFileNames)
5
///
6
/// To use, invoke ACLiC from the ROOT prompt:
7
/// ~~~
8
/// root [] .x QtMultiFileDialog.C++
9
/// ~~~
10
///
11
/// To use it with no ACLiC, omit the trailing "++"
12
/// ~~~
13
/// root [] .x QtMultiFileDialog.C
14
/// ~~~
15
///
16
/// The QtMultiFileDialog creates TList of TObjString objects and
17
/// returns its pointer.
18
///
19
/// The "QtFileDialog.C" macro provides the simplified version of the "QtMultiFileDialog.C"
20
///
21
/// Option: you can change the look and feel of the Qt file dialog
22
/// ======= by providing the optional parameter "style":
23
/// The number of the available styles is defined by your local
24
/// Qt installation.
25
/// Try: "windows", "motif", "kde", "platinum" etc
26
///
27
/// The full list of the Qt classes available from Cint is defined by
28
/// [by $ROOTSYS/cint/lib/qtclasses.h](http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html)
29
///
30
/// All Qt classes can be used from ACLiC though.
31
///
32
/// \macro_code
33
///
34
/// \author Valeri Fine 23/03/2006
35
36
#ifndef __CINT__
37
# include <QApplication>
38
# include <QStyle>
39
# include <QFileDialog>
40
# include <QStringList>
41
# include <QString>
42
# include "
TObjString.h
"
43
# include "
TList.h
"
44
# include <string>
45
#endif
46
TList
*QtMultiFileDialog(
const
char
*
style
=
""
) {
47
48
#ifdef __CINT__
49
// Load the qt cint dictionary.
50
// One is recommended to do that at once somewhere.
51
// For example from one's custom rootlogon.C script
52
gSystem
->
Load
(
"$ROOTSYS/cint/cint/include/qtcint"
);
53
#endif
54
QStyle *saveStyle = 0;
55
if
(!QString(
style
).isEmpty()) {
56
saveStyle =
QApplication::style
();
57
QApplication::setStyle
(
style
);
58
}
59
TList
*listOfNames =
new
TList
();
60
QStringList files = QFileDialog::getOpenFileNames ();
61
QStringList::Iterator it = files.begin();
62
while
( it != files.end() ) {
63
std::string flnm = (*it).toStdString();
64
printf
(
"Next file selected: %s\n"
, flnm.c_str() );
65
// Convert QString to TObjString and add it to the output
66
listOfNames->
Add
(
new
TObjString
(flnm.c_str()));
67
++it;
68
}
69
// Restore the style
70
if
(saveStyle)
QApplication::setStyle
(saveStyle);
71
printf
(
"\nThe TList of the file names contains:"
);
72
printf
(
"\n-------------------------------------\n"
);
73
listOfNames->
ls
();
74
return
listOfNames;
75
}
TObjString
Collectable string class.
Definition:
TObjString.h:32
TCollection::ls
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
Definition:
TCollection.cxx:245
TSystem::Load
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition:
TSystem.cxx:1766
JupyROOT.utils.setStyle
def setStyle
Definition:
utils.py:365
TList.h
TList
A doubly linked list.
Definition:
TList.h:47
TObjString.h
gSystem
R__EXTERN TSystem * gSystem
Definition:
TSystem.h:545
printf
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
style
TCanvas * style()
Definition:
style.C:1
TList::Add
virtual void Add(TObject *obj)
Definition:
TList.h:81