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.

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 328 of file qbytearray.h.

References detach().

Referenced by QLayout::addChildLayout(), QLayout::addChildWidget(), QGridLayout::addWidget(), QAbstractFormBuilder::applyTabStops(), QString::arg(), QBitArray::clearBit(), QMetaObject::connectSlotsByName(), QEucKrCodec::convertFromUnicode(), QSjisCodec::convertFromUnicode(), QGb2312Codec::convertFromUnicode(), QEucJpCodec::convertFromUnicode(), QIsciiCodec::convertFromUnicode(), QTsciiCodec::convertFromUnicode(), QGb18030Codec::convertFromUnicode(), QGbkCodec::convertFromUnicode(), Q3UrlOperator::copyGotData(), QBitArray::count(), QFormBuilder::createLayout(), QAbstractFormBuilder::createProperty(), Q3UriDrag::decode(), Q3Url::decode(), Q3IconDrag::encodedData(), QClipboard::event(), QXmlSimpleReader::feature(), QFSFileEngine::fileName(), QBitArray::fill(), Q3Socket::flush(), QUrl::fromPercentEncoding(), QFont::fromString(), QGLContext::getProcAddress(), Q3CString::leftJustify(), QTextBrowser::loadResource(), QDate::longDayName(), QDate::longMonthName(), Q3LocalFs::operationGet(), QBitArray::operator &=(), operator>>(), QBitArray::operator^=(), QBitArray::operator|=(), QBitArray::operator~(), QBitArray::QBitArray(), qCompress(), QHash< Key, T >::qHash(), QLayout::QLayout(), qUncompress(), QHttp::readAll(), QIODevice::readAll(), Q3Http::readAll(), QIODevice::readLine(), replace(), QBitArray::resize(), rightJustified(), Q3CString::rightJustify(), QBitArray::setBit(), Q3ColorDrag::setColor(), Q3CString::setExpand(), QXmlSimpleReader::setFeature(), QWidget::setLayout(), Q3CString::setNum(), QFSFileEngine::setPermissions(), QFSFileEngine::setSize(), QDate::shortDayName(), QDate::shortMonthName(), Q3Socket::sn_read(), Q3CString::sprintf(), toBase64(), QBitArray::toggleBit(), QString::toLatin1(), toLower(), QDate::toString(), QTime::toString(), toUpper(), QString::toUtf8(), and Q3Socket::writeData().

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


Generated by  Doxygen 1.6.0   Back to index