QIODeviceCopier Class Reference

Data copier for classes deriving from QIODevice. More...

`#include <QHttpEngine/QIODeviceCopier>`

Inheritance diagram for QIODeviceCopier:

## Public Slots

void | start ()
| Start the copy operation. More...
void | stop ()
| Stop the copy operation. More...

## Signals

void | error (const QString &message)
| Indicate that an error occurred.
void | finished ()
| Indicate that the copy operation finished. More...

## Public Member Functions

| QIODeviceCopier (QIODevice *src, QIODevice *dest, QObject *parent=0)
| Create a new device copier from the specified source and destination devices.
void | setBufferSize (qint64 size)
| Set the size of the buffer.

## Detailed Description

QIODeviceCopier provides a set of methods for reading data from a QIODevice and writing it to another. The class operates asynchronously and therefore can be used from the main thread. The copier is initialized with pointers to two QIODevices:

QFile srcFile("src.txt");
QFile destFile("dest.txt");
QIODeviceCopier copier(&srcFile, &destFile);
copier.start()

Notice in the example above that it is not necessary to open the devices prior to starting the copy operation. The copier will attempt to open both devices with the appropriate mode if they are not already open.

If the source device is sequential, data will be read as it becomes available and immediately written to the destination device. If the source device is not sequential, data will be read and written in blocks. The size of the blocks can be modified with the setBufferSize() method.

If an error occurs, the error() signal will be emitted. When the copy completes, either by reading all of the data from the source device or encountering an error, the finished() signal is emitted.

## Member Function Documentation

## finished

void QIODeviceCopier::finished | ( |  | ) |

signal

For sequential devices, this will occur when readChannelFinished() is emitted. For other devices, this signal relies on QIODevice::atEnd() and QIODevice::aboutToClose().

This signal will also be emitted immediately after the error() signal or if the stop() method is invoked.

## start

void QIODeviceCopier::start | ( |  | ) |

slot

The source device will be opened for reading and the destination device opened for writing if applicable. If opening either file fails for some reason, the error() signal will be emitted.

This method should never be invoked more than once.

## stop

void QIODeviceCopier::stop | ( |  | ) |

slot

The start() method should not be invoked after stopping the operation. Instead, a new QIODeviceCopier instance should be created.

The documentation for this class was generated from the following file:

- qiodevicecopier.h

QIODeviceCopier
Data copier for classes deriving from QIODevice.
Definition: qiodevicecopier.h:63