I use QWebEngine to view a website, there is a download popup window show up and i need to download it a folder i set i use this code,
this to get any signal of a download file
ui->widget->load(QUrl(ui->lineEdit->text().trimmed()));
QWebEnginePage *page = ui->widget->page();
QWebEngineProfile *profile = page->profile();
connect(profile, SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(DownloadItem(QWebEngineDownloadItem*)));
then I do this to start accept and download the file in the slot
void MainWindow::DownloadItem(QWebEngineDownloadItem *item)
{
item->setPath("D:/amr.pdf");
connect(item, SIGNAL(finished()), this, SLOT(DownloadFinish()));
connect(item, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
item->accept();
qDebug() << "URL to download = " << item->url().toString();
}
The trick here is after the I download the file, there is a javascript file shows up and ask me to name the file, so the question here how can i get the file name wrote in this javascript dialog, here is an image of how it looks like
so I need a way to get the file name in the slot or anything so i can use this to take this name and name the file before i press ok and the download start.
Thanks.