This code snippet allows programmer to list directories in a parent directory "C:\temp" by using Qt API
#include <QDir>
void list(QStringList& dirnames)
{
QDir currentDir("C:\\temp");
currentDir.setFilter(QDir::Dirs);
QStringList entries = currentDir.entryList();
for( QStringList::ConstIterator entry=entries.begin(); entry!=entries.end(); ++entry )
{
//std::cout << *entry << std::endl;
QString dirname=*entry;
if(dirname != tr(".") && dirname != tr(".."))
{
dirnames.add(dirname);
}
}
}
thank you very much :)
ReplyDelete