PySide6.QtWebEngineCore.QWebEngineDownloadRequest¶
- class QWebEngineDownloadRequest¶
- The - QWebEngineDownloadRequestclass provides information about a download. More…- Synopsis¶- Properties¶
- isFinishedᅟ- Whether this download is finished (completed, cancelled, or non-resumable interrupted state)
- isPausedᅟ- Whether this download is paused
 - Methods¶
- def - id()
- def - isFinished()
- def - isPaused()
- def - mimeType()
- def - page()
- def - receivedBytes()
- def - savePageFormat()
- def - state()
- def - totalBytes()
- def - url()
 - Slots¶- Signals¶- Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QWebEngineDownloadRequestmodels a download throughout its life cycle, starting with a pending download request and finishing with a completed download. It can be used, for example, to get information about new downloads, to monitor progress, and to pause, resume, and cancel downloads.- Downloads are usually triggered by user interaction on a web page. It is the - QWebEngineProfile‘s responsibility to notify the application of new download requests, which it does by emitting the- downloadRequestedsignal together with a newly created- QWebEngineDownloadRequest. The application can then examine this item and decide whether to accept it or not. A signal handler must explicitly call- accept()on the item for Qt WebEngine to actually start downloading and writing data to disk. If no signal handler calls- accept(), then the download request will be automatically rejected and nothing will be written to disk.- Note - Some properties, such as setting the path and file name where the file will be saved (see - downloadDirectory()and- downloadFileName()), can only be changed before calling- accept().- Object Life Cycle¶- All items are guaranteed to be valid during the emission of the - downloadRequestedsignal. If- accept()is not called by any signal handler, then the item will be deleted immediately after signal emission. This means that the application must not keep references to rejected download items. It also means the application should not use a queued connection to this signal.- If - accept()is called by a signal handler, then the- QWebEngineProfilewill take ownership of the item. However, it is safe for the application to delete the item at any time, except during the handling of the- downloadRequestedsignal. The- QWebEngineProfilebeing a long-lived object, it is in fact recommended that the application delete any items it is no longer interested in.- Note - Deleting an item will also automatically cancel a download since 5.12.2, but it is recommended to cancel manually before deleting for portability. - Web Page Downloads¶- In addition to normal file downloads, which consist simply of retrieving some raw bytes from the network and writing them to disk, Qt WebEngine also supports saving complete web pages, which involves parsing the page’s HTML, downloading any dependent resources, and potentially packaging everything into a special file format ( - savePageFormat). To check if a download is for a file or a web page, use- isSavePageDownload.- See also - class DownloadState¶
- This enum describes the state of the download: - Constant - Description - QWebEngineDownloadRequest.DownloadRequested - Download has been requested, but has not been accepted yet. - QWebEngineDownloadRequest.DownloadInProgress - Download is in progress. - QWebEngineDownloadRequest.DownloadCompleted - Download completed successfully. - QWebEngineDownloadRequest.DownloadCancelled - Download has been cancelled. - QWebEngineDownloadRequest.DownloadInterrupted - Download has been interrupted (by the server or because of lost connectivity). 
 - class SavePageFormat¶
- This enum describes the format that is used to save a web page. - Constant - Description - QWebEngineDownloadRequest.UnknownSaveFormat - This is not a request for downloading a complete web page. - QWebEngineDownloadRequest.SingleHtmlSaveFormat - The page is saved as a single HTML page. Resources such as images are not saved. - QWebEngineDownloadRequest.CompleteHtmlSaveFormat - The page is saved as a complete HTML page, for example a directory containing the single HTML page and the resources. - QWebEngineDownloadRequest.MimeHtmlSaveFormat - The page is saved as a complete web page in the MIME HTML format. 
 - class DownloadInterruptReason¶
- Describes the reason why a download was interrupted: - Constant - Description - QWebEngineDownloadRequest.NoReason - Unknown reason or not interrupted. - QWebEngineDownloadRequest.FileFailed - General file operation failure. - QWebEngineDownloadRequest.FileAccessDenied - The file cannot be written locally, due to access restrictions. - QWebEngineDownloadRequest.FileNoSpace - Insufficient space on the target drive. - QWebEngineDownloadRequest.FileNameTooLong - The directory or file name is too long. - QWebEngineDownloadRequest.FileTooLarge - The file size exceeds the file system limitation. - QWebEngineDownloadRequest.FileVirusInfected - The file is infected with a virus. - QWebEngineDownloadRequest.FileTransientError - Temporary problem (for example the file is in use, out of memory, or too many files are opened at once). - QWebEngineDownloadRequest.FileBlocked - The file was blocked due to local policy. - QWebEngineDownloadRequest.FileSecurityCheckFailed - An attempt to check the safety of the download failed due to unexpected reasons. - QWebEngineDownloadRequest.FileTooShort - An attempt was made to seek past the end of a file when opening a file (as part of resuming a previously interrupted download). - QWebEngineDownloadRequest.FileHashMismatch - The partial file did not match the expected hash. - QWebEngineDownloadRequest.NetworkFailed - General network failure. - QWebEngineDownloadRequest.NetworkTimeout - The network operation has timed out. - QWebEngineDownloadRequest.NetworkDisconnected - The network connection has been terminated. - QWebEngineDownloadRequest.NetworkServerDown - The server has gone down. - QWebEngineDownloadRequest.NetworkInvalidRequest - The network request was invalid (for example, the original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy). - QWebEngineDownloadRequest.ServerFailed - General server failure. - QWebEngineDownloadRequest.ServerBadContent - The server does not have the requested data. - QWebEngineDownloadRequest.ServerUnauthorized - The server did not authorize access to the resource. - QWebEngineDownloadRequest.ServerCertProblem - A problem with the server certificate occurred. - QWebEngineDownloadRequest.ServerForbidden - Access forbidden by the server. - QWebEngineDownloadRequest.ServerUnreachable - Unexpected server response (might indicate that the responding server may not be the intended server). - QWebEngineDownloadRequest.UserCanceled - The user canceled the download. 
 - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property downloadDirectoryᅟ: str¶
 - Access functions:
 - property downloadFileNameᅟ: str¶
 - Access functions:
 - property idᅟ: int¶
 - Access functions:
 - property interruptReasonᅟ: QWebEngineDownloadRequest.DownloadInterruptReason¶
 - Access functions:
 - property interruptReasonStringᅟ: str¶
 - Access functions:
 - property isFinishedᅟ: bool¶
 - This property holds Whether this download is finished (completed, cancelled, or non-resumable interrupted state).. - See also - Access functions:
- Signal - isFinishedChanged()
 
 - property isPausedᅟ: bool¶
 - This property holds Whether this download is paused.. - Access functions:
- Signal - isPausedChanged()
 
 - property isSavePageDownloadᅟ: bool¶
 - Access functions:
 - property mimeTypeᅟ: str¶
 - Access functions:
 - property receivedBytesᅟ: int¶
 - Access functions:
 - property savePageFormatᅟ: QWebEngineDownloadRequest.SavePageFormat¶
 - Access functions:
 - property stateᅟ: QWebEngineDownloadRequest.DownloadState¶
 - Access functions:
- Signal - stateChanged()
 
 - property suggestedFileNameᅟ: str¶
 - Access functions:
 - property totalBytesᅟ: int¶
 - Access functions:
- Signal - totalBytesChanged()
 
 - Access functions:
 - accept()¶
 - Accepts the current download request, which will start the download. - If the item is in the - DownloadRequestedstate, then it will transition into the- DownloadInProgressstate and the downloading will begin. If the item is in any other state, then nothing will happen.- See also - cancel()¶
 - Cancels the current download. - If the item is in the - DownloadInProgressstate, then it will transition into the- DownloadCancelledstate, the downloading will stop, and partially downloaded files will be deleted from disk.- If the item is in the - DownloadCompletedstate, then nothing will happen. If the item is in any other state, then it will transition into the- DownloadCancelledstate without further effect.- See also - downloadDirectory()¶
- Return type:
- str 
 
 - Returns the download directory path. - See also - Getter of property - downloadDirectoryᅟ.- downloadDirectoryChanged()¶
 - Notification signal of property - downloadDirectoryᅟ.- downloadFileName()¶
- Return type:
- str 
 
 - Returns the file name to download the file to. - See also - Getter of property - downloadFileNameᅟ.- downloadFileNameChanged()¶
 - Notification signal of property - downloadFileNameᅟ.- id()¶
- Return type:
- int 
 
 - Returns the download item’s ID. - Getter of property - idᅟ.- interruptReason()¶
- Return type:
 
 - Returns the reason why the download was interrupted. - See also - Getter of property - interruptReasonᅟ.- interruptReasonChanged()¶
 - Notification signal of property - interruptReasonᅟ.- interruptReasonString()¶
- Return type:
- str 
 
 - Returns a human-readable description of the reason for interrupting the download. - See also - Getter of property - interruptReasonStringᅟ.- isFinished()¶
- Return type:
- bool 
 
 - Getter of property - isFinishedᅟ.- isFinishedChanged()¶
 - Notification signal of property - isFinishedᅟ.- isPaused()¶
- Return type:
- bool 
 
 - Getter of property - isPausedᅟ.- isPausedChanged()¶
 - This signal is emitted whenever - isPausedchanges.- Notification signal of property - isPausedᅟ.- isSavePageDownload()¶
- Return type:
- bool 
 
 - Returns - trueif this is a download request for saving a web page.- See also - Getter of property - isSavePageDownloadᅟ.- mimeType()¶
- Return type:
- str 
 
 - Returns the MIME type of the download. - Getter of property - mimeTypeᅟ.- page()¶
- Return type:
 
 - Returns the page the download was requested on. If the download was not triggered by content in a page, - nullptris returned.- pause()¶
 - Pauses the download. - Has no effect if the state is not - DownloadInProgress. Does not change the state.- See also - receivedBytes()¶
- Return type:
- int 
 
 - Returns the amount of data in bytes that has been downloaded so far. - -1means the size is unknown.- Getter of property - receivedBytesᅟ.- receivedBytesChanged()¶
 - Notification signal of property - receivedBytesᅟ.- resume()¶
 - Resumes the current download if it was paused or interrupted. - Has no effect if the state is not - DownloadInProgressor- DownloadInterrupted. Does not change the state.- See also - savePageFormat()¶
- Return type:
 
 - Returns the format the web page will be saved in if this is a download request for a web page. - See also - Getter of property - savePageFormatᅟ.- savePageFormatChanged()¶
 - Notification signal of property - savePageFormatᅟ.- setDownloadDirectory(directory)¶
- Parameters:
- directory – str 
 
 - Sets - directoryas the directory path to download the file to.- The download directory path can only be set in response to the - downloadRequested()signal before the download is accepted. Past that point, this function has no effect on the download item’s state.- See also - Setter of property - downloadDirectoryᅟ.- setDownloadFileName(fileName)¶
- Parameters:
- fileName – str 
 
 - Sets - fileNameas the file name to download the file to.- The download file name can only be set in response to the - downloadRequested()signal before the download is accepted. Past that point, this function has no effect on the download item’s state.- See also - Setter of property - downloadFileNameᅟ.- setSavePageFormat(format)¶
- Parameters:
- format – - SavePageFormat
 
 - Sets the - formatthe web page will be saved in if this is a download request for a web page.- See also - Setter of property - savePageFormatᅟ.- state()¶
- Return type:
 
 - Returns the download item’s current state. - See also - Getter of property - stateᅟ.- stateChanged(state)¶
- Parameters:
- state – - DownloadState
 
 - This signal is emitted whenever the download’s - statechanges.- See also - Notification signal of property - stateᅟ.- suggestedFileName()¶
- Return type:
- str 
 
 - Returns the suggested file name. - Getter of property - suggestedFileNameᅟ.- totalBytes()¶
- Return type:
- int 
 
 - Returns the total amount of data to download in bytes. - -1means the size is unknown.- Getter of property - totalBytesᅟ.- totalBytesChanged()¶
 - Notification signal of property - totalBytesᅟ.- Returns the download’s origin URL. - Getter of property - urlᅟ.