1

I am learning pyqt5 and built a simple webbrowser in pyqt5 webengine . Now out of curiosity I want to know that is there a method by which I am able to download files using this minimalistic browser,Thanks in advance.

import sys
from PyQt5 import QtWidgets,QtGui,QtCore
from PyQt5.QtWebEngineWidgets import *
app=QtWidgets.QApplication(sys.argv)
w=QWebEngineView()
w.page().fullScreenRequested.connect(QWebEngineFullScreenRequest.accept)
w.load(QtCore.QUrl('https://google.com'))
w.showMaximized()
app.exec_()
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

3

The simplest possible way to download would be something like this...

def _downloadRequested(item): # QWebEngineDownloadItem
    print('downloading to', item.path())
    item.accept()

w.page().profile().downloadRequested.connect(_downloadRequested)
shao.lo
  • 4,387
  • 2
  • 33
  • 47