Solved Select folder and upload all files from folder to server
-
@the_ I am new in qt I don't know how to implement too confused
-
@developerNancy
Which part of the documentation don't you understand and what did you try so far? -
@the_ I have almost done but I want only files......
-
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, sorry -
@developerNancy Would be great if you could provide me with some working example of this.
Thanks
-
@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);
-
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::Filters -
@the_ Thanks....
-
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 ;) -
@the_
Good point
But will
"*"
match all files , even on windows ? -
@mrjj
Not 100% sure if it matches all files but should do with all visible files. -
@the_ Its working using this QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags)