Solved QFileDialog, if cancel pressed
-
Is it possible know if cancel was pressed in filedialog without filedialog instance?
QDir dir = QFileDialog::getExistingDirectory(this, "Select folder", loadFileDirSet("folderSave"),QFileDialog::ShowDirsOnly);
-
Hi,
That method returns a QString, check that the return string is not null and you'll know if it was cancelled.
-
@SGaist Yes , using QDir is wrong there , but it gives easy acess to
dir.entryInfoList(QDir::Files,QDir::Name)
-
@Q139 You can easily create QDir instance from the string returned from getExistingDirectory() using https://doc.qt.io/qt-5/qdir.html#QDir-2
-
@jsulm getExistingDirectory() returns null in case the window poped up was canceled or closed mannually. I got an error from trying to check QString 's value in this way
QString oQStrPath;
oQStrPath = QFileDialog::getExistingDirectory(this, "Local data path ...", oQDCurDir.absolutePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
if(oQStrPath.isNull()) // error is here and rediected to vector.h by qtcreator's compiler
// To do something -
@Make-it-GREAT-again said in QFileDialog, if cancel pressed:
error is here and rediected to vector.h by qtcreator's compiler
What error exactly? There is no QtCreator compiler, QtCreator uses compiler set in the Kit you're using.
-
@jsulm I found it. Thanks for reply.