Select folder and upload all files from folder to server
-
@developerNancy
Which part of the documentation don't you understand and what did you try so far?wrote on 5 May 2017, 12:07 last edited by@the_ I have almost done but I want only files......
-
@the_ I have almost done but I want only files......
wrote on 5 May 2017, 12:18 last edited by the_ 5 May 2017, 12:23If you only want the files within a folder just apply the correct
QDir::Filters
to theQDirIterator
.
Just a guess:QDir::Files
as can be found in http://doc.qt.io/qt-5/qdir.html#Filter-enum--EDIT
QDir::NoDotAndDotDot
is not neccessary if you useQDir::Files
as.
and..
are folders and not files. my bad, sorry -
@the_ I have almost done but I want only files......
wrote on 5 May 2017, 12:19 last edited by@developerNancy Would be great if you could provide me with some working example of this.
Thanks
-
If you only want the files within a folder just apply the correct
QDir::Filters
to theQDirIterator
.
Just a guess:QDir::Files
as can be found in http://doc.qt.io/qt-5/qdir.html#Filter-enum--EDIT
QDir::NoDotAndDotDot
is not neccessary if you useQDir::Files
as.
and..
are folders and not files. my bad, sorrywrote on 5 May 2017, 12:31 last edited by developerNancy 5 May 2017, 12:31@the_ said what I have to change
QString UploadFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home",QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks); QDirIterator UploadFolderFiles(UploadFolder, QDirIterator::Subdirectories); while (UploadFolderFiles.hasNext()) { qDebug() << UploadFolderFiles.next(); } this->uploadLine->setText(UploadFolder);
-
@the_ said what I have to change
QString UploadFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home",QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks); QDirIterator UploadFolderFiles(UploadFolder, QDirIterator::Subdirectories); while (UploadFolderFiles.hasNext()) { qDebug() << UploadFolderFiles.next(); } this->uploadLine->setText(UploadFolder);
wrote on 5 May 2017, 12:40 last edited byJust use
QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags)
instead ofQDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags = NoIteratorFlags)
as your constructor and apply the filters you need as listed in QDir::Filters -
Just use
QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags)
instead ofQDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags = NoIteratorFlags)
as your constructor and apply the filters you need as listed in QDir::Filterswrote on 5 May 2017, 13:10 last edited by@the_ Thanks....
-
@the_ Thanks....
Lifetime Qt Championwrote on 5 May 2017, 16:56 last edited by mrjj 5 May 2017, 16:57So in short, it is like first shown
QDirIterator it(dir, QStringList() << "*.*", QDir::Files, QDirIterator::Subdirectories);
The
QStringList() << "*.*"
tell what files you are after.
If you dont tell it, it seems to think u say "i dont want any files" which makes sense.
-
So in short, it is like first shown
QDirIterator it(dir, QStringList() << "*.*", QDir::Files, QDirIterator::Subdirectories);
The
QStringList() << "*.*"
tell what files you are after.
If you dont tell it, it seems to think u say "i dont want any files" which makes sense.
-
@mrjj
With the difference that*.*
does only match files that contain a dot but misses all files without file extension ;)Lifetime Qt Championwrote on 5 May 2017, 17:22 last edited by mrjj 5 May 2017, 17:23@the_
Good point
But will
"*"
match all files , even on windows ? -
wrote on 6 May 2017, 04:30 last edited by
@the_ Its working using this QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags)
27/28