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

QByteArray QIODevice::readAll (  )  [inherited]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Reads all available data from the device, and returns it as a QByteArray.

This function has no way of reporting errors; returning an empty QByteArray() can mean either that no data was currently available for reading, or that an error occurred.

Definition at line 937 of file qiodevice.cpp.

References QIODevice::bytesAvailable(), QByteArray::chop(), QByteArray::data(), QIODevice::read(), QByteArray::resize(), QByteArray::size(), and QIODevice::size().

Referenced by QFontDatabase::addApplicationFont(), QSslCertificate::fromDevice(), QSslCertificate::fromPath(), QPicture::load(), TextEdit::loadResource(), QTextBrowser::loadResource(), MainWindow::openFile(), FindFileDialog::openFile(), QSslCertificate::QSslCertificate(), QSslKey::QSslKey(), QProcess::readAllStandardError(), QProcess::readAllStandardOutput(), QHelpProjectData::readData(), QSslSocket::setLocalCertificate(), and QSslSocket::setPrivateKey().

    printf("%p QIODevice::readAll(), d->pos = %d, d->buffer.size() = %d\n",
           this, int(d->pos), int(d->buffer.size()));

    QByteArray tmp;
    if (d->isSequential() || size() == 0) {
        // Read it in chunks, bytesAvailable() is unreliable for sequential
        // devices.
        const int chunkSize = 4096;
        qint64 totalRead = 0;
        forever {
            tmp.resize(tmp.size() + chunkSize);
            qint64 readBytes = read(tmp.data() + totalRead, chunkSize);
            tmp.chop(chunkSize - (readBytes < 0 ? 0 : readBytes));
            if (readBytes <= 0)
                return tmp;
            totalRead += readBytes;
    } else {
        // Read it all in one go.
        qint64 readBytes = read(tmp.data(), tmp.size());
        tmp.resize(readBytes < 0 ? 0 : int(readBytes));
    return tmp;

Generated by  Doxygen 1.6.0   Back to index