There is a Qt Quick application which allows the user to open some type of a file. The folder property of the file dialog is bound to the property of the application class (in my case it is faveFolder) and the application may change the value of this property. Thus I would expect the FileDialog to be positioned on the new folder. In fact, it respects only the initial value of the property.

My QML code is shown below:
Qt Code:
  1. import QtQuick 2.7
  2. import QtQuick.Window 2.2
  3. import QtQuick.Dialogs 1.2
  4.  
  5. Window
  6. {
  7. visible: true
  8.  
  9. MouseArea
  10. {
  11. anchors.fill: parent
  12.  
  13. FileDialog
  14. {
  15. id: fileDialog
  16. title: "Please choose a file"
  17. nameFilters: "NZB Files (*.nzb)"
  18. folder: app.faveFolder // binding to the property of Application
  19.  
  20. onAccepted:
  21. {
  22. //nzbFileDialog.folder = "file:///Z:/";
  23. app.openFile(fileDialog.fileUrl);
  24. print("new folder: " + fileDialog.folder);
  25.  
  26. // ! this line magically solves the issue :)
  27. //fileDialog.folder = fileDialog.folder;
  28. }
  29. } // FileDialog
  30.  
  31. onClicked:
  32. {
  33. print("app.faveFolder = " + app.faveFolder + " fileDialog.folder = " + fileDialog.folder);
  34. fileDialog.visible = true;
  35. //fileDialog.open();
  36. }
  37. }
  38.  
  39. Text
  40. {
  41. text: qsTr("Click to open")
  42. anchors.centerIn: parent
  43. }
  44. }
To copy to clipboard, switch view to plain text mode 

The Application instance (app) is passed to QML in main.cpp:
Qt Code:
  1. #include "application.h"
  2.  
  3. //#include <QGuiApplication>
  4. #include <QQmlApplicationEngine>
  5. #include <QQmlContext>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. Application app(argc, argv);
  10.  
  11. QQmlApplicationEngine engine;
  12. engine.rootContext()->setContextProperty("app", &app);
  13. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  14.  
  15. return app.exec();
  16. }
To copy to clipboard, switch view to plain text mode 

Application.h:
Qt Code:
  1. #ifndef APPLICATION_H
  2. #define APPLICATION_H
  3.  
  4. #include <QGuiApplication>
  5.  
  6. class Application: public QGuiApplication
  7. {
  8. Q_OBJECT
  9.  
  10. //Q_PROPERTY(QString nzbFolder MEMBER nzbDir NOTIFY nzbFolderChanged)
  11. Q_PROPERTY(QString faveFolder MEMBER faveDir NOTIFY faveFolderChanged)
  12.  
  13. public:
  14. Application(int argc, char * argv[]);
  15.  
  16. Q_INVOKABLE void openFile(const QString &filePath);
  17.  
  18. signals:
  19. void faveFolderChanged();
  20. //void faveFolderChanged(const QString &newPath);
  21.  
  22. private:
  23. QString faveDir;
  24. };
  25.  
  26. #endif // APPLICATION_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "application.h"
  2.  
  3. #include <QUrl>
  4. #include <QFileInfo>
  5. #include <QDebug>
  6.  
  7. Application::Application(int argc, char * argv[]): QGuiApplication(argc, argv)
  8. {
  9. this->faveDir = "file:///D:/temp"; // set the initial value
  10. }
  11.  
  12. void Application::openFile(const QString &filePath)
  13. {
  14. qDebug() << filePath;
  15. this->faveDir = "file:///Z:/"; // set the new value
  16. //this->faveDir = QUrl::fromLocalFile(QFileInfo(QUrl(filePath).toLocalFile()).absolutePath()).toString();
  17. qDebug() << this->faveDir;
  18. emit faveFolderChanged();
  19. //emit faveFolderChanged(this->faveDir);
  20. }
To copy to clipboard, switch view to plain text mode 

This is what was printed to the output window:
qml: app.faveFolder = file:///D:/temp fileDialog.folder = file:///D:/temp
"file:///Z:/crash_part29.nzb"
"file:///Z:/"
qml: new folder: file:///Z:/
qml: app.faveFolder = file:///Z:/ fileDialog.folder = file:///Z:/
As a one can see from the last line, which is printed right before showing the file dialog, it does have the updated value. In spite of this, when opened FileDialog is still positioned to the old folder. And the interesting thing here is that uncommenting the line "fileDialog.folder = fileDialog.folder" somehow solves the issue.