- Qt 5.5
- Qt WebEngine Widgets
- C++ Classes
- QWebEngineDownloadItem
- Qt 5.5.1 Reference Documentation

# QWebEngineDownloadItem Class

The QWebEngineDownloadItem class provides information about a download. More...

Header: | #include <QWebEngineDownloadItem>
qmake: | QT += webenginewidgets
Since: | Qt 5.5
Inherits: |

- List of all members, including inherited members

## Public Types

enum | DownloadState { DownloadRequested, DownloadInProgress, DownloadCompleted, DownloadCancelled, DownloadInterrupted }

## Public Functions

quint32 | id() const
bool | isFinished() const
QString | path() const
qint64 | receivedBytes() const
void | setPath(QString path)
DownloadState | state() const
qint64 | totalBytes() const
QUrl | url() const

## Public Slots

void | accept()
void | cancel()

## Signals

void | downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
void | finished()
void | stateChanged(DownloadState state)

## Detailed Description

The QWebEngineDownloadItem class provides information about a download.

QWebEngineDownloadItem stores the state of a download to be used to manage requested downloads.

## Member Type Documentation

### enum QWebEngineDownloadItem::DownloadState

This enum describes the state of the download:

Constant | Value | Description
--- | --- | ---
`QWebEngineDownloadItem::DownloadRequested` | `0` | Download has been requested, but has not been accepted yet.
`QWebEngineDownloadItem::DownloadInProgress` | `1` | Download is in progress.
`QWebEngineDownloadItem::DownloadCompleted` | `2` | Download completed successfully.
`QWebEngineDownloadItem::DownloadCancelled` | `3` | Download has been cancelled.
`QWebEngineDownloadItem::DownloadInterrupted` | `4` | Download has been interrupted (by the server or because of lost connectivity).

## Member Function Documentation

### `[slot]` void QWebEngineDownloadItem::accept()

Accepts the current download request, which will start the download.

See also finished() and stateChanged().

### `[slot]` void QWebEngineDownloadItem::cancel()

Cancels the current download.

See also finished() and stateChanged().

### `[signal]` void QWebEngineDownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)

This signal is emitted whenever the download's bytesReceived or bytesTotal changes.

See also totalBytes() and receivedBytes().

### `[signal]` void QWebEngineDownloadItem::finished()

This signal is emitted whenever the download finishes.

See also state() and isFinished().

### quint32 QWebEngineDownloadItem::id() const

Returns the download item's ID.

### bool QWebEngineDownloadItem::isFinished() const

Returns whether this download is finished (not in progress).

See also finished() and state().

### QString QWebEngineDownloadItem::path() const

Returns the full target path where data is being downloaded to.

The path includes the file name. The default suggested path is the standard download location and file name is deduced not to overwrite already existing files.

See also setPath().

### qint64 QWebEngineDownloadItem::receivedBytes() const

Returns the amount of data in bytes that has been downloaded so far.

`-1` means the size is unknown.

### void QWebEngineDownloadItem::setPath(QString path)

Sets the full target path to download the file to.

The path should also include the file name. The download path can only be set in response to the QWebEngineProfile::downloadRequested() signal before the download is accepted. Past that point, this function has no effect on the download item's state.

See also path().

### DownloadState QWebEngineDownloadItem::state() const

Returns the download item's current state.

See also QWebEngineDownloadItem::DownloadState.

### `[signal]` void QWebEngineDownloadItem::stateChanged(DownloadState state)

This signal is emitted whenever the download's state changes.

See also state() and QWebEngineDownloadItem::DownloadState.

### qint64 QWebEngineDownloadItem::totalBytes() const

Returns the the total amount of data to download in bytes.

`-1` means the size is unknown.

### QUrl QWebEngineDownloadItem::url() const

Returns the download's origin URL.