Logo Search packages:      
Sourcecode: qt4-x11 version File versions

qint64 QIODevice::peek ( char *  data,
qint64  maxSize 
) [inherited]

Since:
4.1
Reads at most maxSize bytes from the device into data, without side effects (i.e., if you call read() after peek(), you will get the same data). Returns the number of bytes read. If an error occurs, such as when attempting to peek a device opened in WriteOnly mode, this function returns -1.

0 is returned when no more data is available for reading.

Example:

doc/src/snippets/code/src.corelib.io.qiodevice.cpp 4

See also:
read()

Definition at line 1393 of file qiodevice.cpp.

References QIODevice::read(), and QIODevice::ungetChar().

{
    qint64 readBytes = read(data, maxSize);
    int i = readBytes;
    while (i > 0)
        ungetChar(data[i-- - 1]);
    return readBytes;
}


Generated by  Doxygen 1.6.0   Back to index