Hello my friend,
look at this little snippet from me perhaps it will help you.
QString somepath
= "C:/yourpathtofolder/" somefolder.
setFilter(QDir::Files |
QDir::Dirs |
QDir::NoSymLinks);
somefolder.
setSorting(QDir::Size |
QDir::Reversed);
for (int i(0); i < filenames.count(); i++)
{
//you can also ignore the if statement for filtering your Filenames depends on your filtertext
QDir dir
(somepath
+filenames.
at(i
));
{
if(file.contains("YourFilterText", Qt::CaseInsensitive))
fileListing <<
QFileInfo( dir,
file).
absoluteFilePath() <<
"\n";
}
}
//after you fill up your list and do want you want to do my friend ;o))
{
QMessageBox::information(this, tr
("My Files in Folder"),
tr("File: %1 "
" ")
.arg(str));
}
fileListing.clear();
QString somepath = "C:/yourpathtofolder/"
QDir somefolder = QDir(somepath);
somefolder.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks);
somefolder.setSorting(QDir::Size | QDir::Reversed);
QStringList filenames = somefolder.entryList(QDir::NoDotAndDotDot | QDir::AllDirs, QDir::Name);
QStringList fileListing;
for (int i(0); i < filenames.count(); i++)
{
QString str = filenames.at(i);
//you can also ignore the if statement for filtering your Filenames depends on your filtertext
QDir dir(somepath+filenames.at(i));
foreach ( QString file, dir.entryList( QDir::Files))
{
if(file.contains("YourFilterText", Qt::CaseInsensitive))
fileListing << QFileInfo( dir, file).absoluteFilePath() << "\n";
}
}
//after you fill up your list and do want you want to do my friend ;o))
foreach (QString str, fileListing)
{
QMessageBox::information(this, tr("My Files in Folder"),
tr("File: %1 "
" ")
.arg(str));
}
fileListing.clear();
To copy to clipboard, switch view to plain text mode
I hope I don´t make any mistake, please proof it before using ;o))
bye
Bookmarks