How to get signal and download link from WebView
-
@mikeeeeee hi,
google qml WebView download
its shorter than the question you typed 2 times for some reason
-
@mikeeeeee said in How to get signal and download link from WebView:
download signal
What signal is that? Do you mean if the user clicks on a link, or what?
-
@mikeeeeee said in How to get signal and download link from WebView:
I need to get the download signal and download link.
im not sure what that means
-
In c++ this work, how I can get signal for download in QML?
MainWindow::MainWindow(QWidget parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->webView->page()->setForwardUnsupportedContent(true);
connect(ui->webView->page(),SIGNAL(downloadRequested(QNetworkRequest)),this,SLOT(download(QNetworkRequest)));
connect(ui->webView->page(),SIGNAL(unsupportedContent(QNetworkReply)),this,SLOT(unsupportedContent(QNetworkReply*)));
}MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::download(const QNetworkRequest &request){
// request.url() - это то, откуда вам нужно скачать файл или изображение
qDebug()<<"Download Requested: "<<request.url();
}void MainWindow::unsupportedContent(QNetworkReply * reply){
qDebug()<<"Unsupported Content: "<<reply->url();
}
-
Set a proper WebEngineProfile to your
WebEngineView
, then usedownloadRequested
signal. -
Looks like there is no easy solution for Android. If you are good enough in Java and JNI you can probably change QtAndroidWebViewController and set download listener. Not sure if it possible, just quick look into it leads me there.