If anyone comes here for solution, please read below reply from QT support team which I got.
You need to block the execution in the handler until the
download location has been set.
Like below:
In BrowserWindow.qml
import Test 1.0
FileDialog {
id: fd
selectFolder: true
property bool done: false
onAccepted: {
done = true
}
onRejected: done = true
}
function onDownloadRequested(download) {
fd.done = false
fd.open()
while(!fd.done) {
App.process()
}
download.downloadDirectory = App.urlToDir(fd.folder)
downloadView.visible = true;
downloadView.append(download);
download.accept();
}
In cpp files:
class App : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE QString urlToDir(QUrl url)
{
return url.toLocalFile();
}
Q_INVOKABLE void process()
{
qApp->processEvents();
}
};
int main(int argc, char **argv)
{
///all initialization code and including QApplication creation
qmlRegisterSingletonInstance("Test", 1, 0, "App", new App);
}
Regards,
Sheetal