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

char * QByteArray::data (  )  [inline]

Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated.

Example:

        QByteArray ba("Hello world");
        char *data = ba.data();
        while (*data) {
            cout << "[" << *data << "]" << endl;
            ++data;
        }

The pointer remains valid as long as the byte array isn't reallocated. For read-only access, constData() is faster because it never causes a {deep copy} to occur.

This function is mostly useful to pass a byte array to a function that accepts a {const char *}.

Note: A QByteArray can store any byte values including '\0's, but most functions that take {char *} arguments assume that the data ends at the first '\0' they encounter.

See also:
constData(), operator[]()

Definition at line 365 of file qbytearray.h.

References detach().

Referenced by QLayout::addChildLayout(), QLayout::addChildWidget(), QResource::addSearchPath(), QGridLayout::addWidget(), QString::arg(), QBitArray::clearBit(), QMetaObject::connectSlotsByName(), QEucKrCodec::convertFromUnicode(), QSjisCodec::convertFromUnicode(), QGb2312Codec::convertFromUnicode(), QEucJpCodec::convertFromUnicode(), QIsciiCodec::convertFromUnicode(), QTsciiCodec::convertFromUnicode(), QGbkCodec::convertFromUnicode(), QGb18030Codec::convertFromUnicode(), Q3UrlOperator::copyGotData(), QBitArray::count(), Q3UriDrag::decode(), Q3Url::decode(), QRasterPaintEngine::drawTextItem(), Q3IconDrag::encodedData(), QClipboard::event(), QXmlSimpleReader::feature(), QXmlInputSource::fetchData(), QFSFileEngine::fileFlags(), QFSFileEngine::fileName(), QBitArray::fill(), Q3Socket::flush(), fromHex(), QUrl::fromPercentEncoding(), QFont::fromString(), QGLContext::getProcAddress(), Q3CString::leftJustify(), QTextBrowser::loadResource(), Q3LocalFs::operationGet(), QBitArray::operator &=(), Q3TextStream::operator<<(), operator>>(), Q3TextStream::operator>>(), QBitArray::operator^=(), QBitArray::operator|=(), QBitArray::operator~(), QBitArray::QBitArray(), qCompress(), QLayout::QLayout(), qUncompress(), QHttp::readAll(), Q3Http::readAll(), QIODevice::readAll(), QIODevice::readLine(), QResource::registerResource(), replace(), QBitArray::resize(), QCryptographicHash::result(), rightJustified(), Q3CString::rightJustify(), QBitArray::setBit(), Q3ColorDrag::setColor(), Q3CString::setExpand(), QXmlSimpleReader::setFeature(), QWidget::setLayout(), Q3CString::setNum(), Q3Socket::sn_read(), Q3CString::sprintf(), toBase64(), QBitArray::toggleBit(), toHex(), QString::toLatin1(), toLower(), QSslKey::toPem(), toUpper(), QString::toUtf8(), and Q3Socket::writeData().

{ detach(); return d->data; }


Generated by  Doxygen 1.6.0   Back to index