QDir, list all directories?
How can I list/take only directories from a directory?
E.g.
Code:
directory.setFolderMode(); //example ! :P
directory.setCurrent("/home/alex/");
for (int i =0; i > directory.count(); i++){
directory.at(i) //mpla mpla...
}
Very sample code, it's just to understand what i want to achieve...
Well, that's what i want to do... Take the subfolder names from a specific dir and perform some actions with each one separately...
Is there any way to do this?
Re: QDir, list all directories?
Look at the filters argument to the QDir constructor or QDir::setFilter()
Re: QDir, list all directories?
the setfilter takes qstring as argument....Cannot filer the dirs...!
Re: QDir, list all directories?
QDir::setFilter() does not take a QString argument, something you would have noticed if you bothered the read the documentation before declaring that it "Cannot filter the dirs...!". Similarly, the filters argument to the constructor does not take a QString argument.
Re: QDir, list all directories?
Re: QDir, list all directories?
For a reason, I get error out of index or something like this with this solution........ :/
Re: QDir, list all directories?
As you said yourself, it's for a reason.
Re: QDir, list all directories?
Re: QDir, list all directories?
Code:
all_dirs << parent_folder;
QDirIterator directories
(parent_folder,
QDir::Dirs |
QDir::NoSymLinks |
QDir::NoDotAndDotDot, QDirIterator
::Subdirectories);
while(directories.hasNext()){
directories.next();
all_dirs << directories.filePath();
}
Where parent_folder is the folder whose you want all of his subdirectories.
Re: QDir, list all directories?
Quote:
Originally Posted by
hakermania
How can I list/take only directories from a directory?
E.g.
Code:
directory.setFolderMode(); //example ! :P
directory.setCurrent("/home/alex/");
for (int i =0; i > directory.count(); i++){
directory.at(i) //mpla mpla...
}
Very sample code, it's just to understand what i want to achieve...
Well, that's what i want to do... Take the subfolder names from a specific dir and perform some actions with each one separately...
Is there any way to do this?
QDir::at() and QDir::setFolderMode() are not real , are they ? because they're not on Qt 5 at least.
Re: QDir, list all directories?
Look at QDir::entryList() or QDir::entryInfoList() depending on whether you just need the directory names or more info like modification dates, etc.