Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QBuffer Class Reference

\inmodule QtCore \reentrant More...

#include <qbuffer.h>

+ Inheritance diagram for QBuffer:
+ Collaboration diagram for QBuffer:

Public Member Functions

 QBuffer (QObject *parent=nullptr)
 Constructs an empty buffer with the given parent.
 
 QBuffer (QByteArray *buf, QObject *parent=nullptr)
 Constructs a QBuffer that uses the QByteArray pointed to by byteArray as its internal buffer, and with the given parent.
 
 ~QBuffer ()
 Destroys the buffer.
 
QByteArraybuffer ()
 Returns a reference to the QBuffer's internal buffer.
 
const QByteArraybuffer () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This is the same as data().
 
void setBuffer (QByteArray *a)
 Makes QBuffer use the QByteArray pointed to by byteArray as its internal buffer.
 
void setData (const QByteArray &data)
 Sets the contents of the internal buffer to be data.
 
void setData (const char *data, qsizetype len)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the contents of the internal buffer to be the first size bytes of data.
 
const QByteArraydata () const
 Returns the data contained in the buffer.
 
bool open (OpenMode openMode) override
 \reimp
 
void close () override
 \reimp
 
qint64 size () const override
 \reimp
 
qint64 pos () const override
 \reimp
 
bool seek (qint64 off) override
 \reimp
 
bool atEnd () const override
 \reimp
 
bool canReadLine () const override
 \reimp
 
- Public Member Functions inherited from QIODevice
 QIODevice ()
 Constructs a QIODevice object.
 
 QIODevice (QObject *parent)
 Constructs a QIODevice object with the given parent.
 
virtual ~QIODevice ()
 The destructor is virtual, and QIODevice is an abstract base class.
 
QIODeviceBase::OpenMode openMode () const
 Returns the mode in which the device has been opened; i.e.
 
void setTextModeEnabled (bool enabled)
 If enabled is true, this function sets the \l Text flag on the device; otherwise the \l Text flag is removed.
 
bool isTextModeEnabled () const
 Returns true if the \l Text flag is enabled; otherwise returns false.
 
bool isOpen () const
 Returns true if the device is open; otherwise returns false.
 
bool isReadable () const
 Returns true if data can be read from the device; otherwise returns false.
 
bool isWritable () const
 Returns true if data can be written to the device; otherwise returns false.
 
virtual bool isSequential () const
 Returns true if this device is sequential; otherwise returns false.
 
int readChannelCount () const
 
int writeChannelCount () const
 
int currentReadChannel () const
 
void setCurrentReadChannel (int channel)
 
int currentWriteChannel () const
 
void setCurrentWriteChannel (int channel)
 
virtual bool open (QIODeviceBase::OpenMode mode)
 Opens the device and sets its OpenMode to mode.
 
virtual void close ()
 First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
 
virtual qint64 pos () const
 For random-access devices, this function returns the position that data is written to or read from.
 
virtual qint64 size () const
 For open random-access devices, this function returns the size of the device.
 
virtual bool seek (qint64 pos)
 For random-access devices, this function sets the current position to pos, returning true on success, or false if an error occurred.
 
virtual bool atEnd () const
 Returns true if the current read and write position is at the end of the device (i.e.
 
virtual bool reset ()
 Seeks to the start of input for random-access devices.
 
virtual qint64 bytesAvailable () const
 Returns the number of bytes that are available for reading.
 
virtual qint64 bytesToWrite () const
 For buffered devices, this function returns the number of bytes waiting to be written.
 
qint64 read (char *data, qint64 maxlen)
 Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
 
QByteArray read (qint64 maxlen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads at most maxSize bytes from the device, and returns the data read as a QByteArray.
 
QByteArray readAll ()
 Reads all remaining data from the device, and returns it as a byte array.
 
qint64 readLine (char *data, qint64 maxlen)
 This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes, stores the characters in data, and returns the number of bytes read.
 
QByteArray readLine (qint64 maxlen=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads a line from the device, but no more than maxSize characters, and returns the result as a byte array.
 
virtual bool canReadLine () const
 Returns true if a complete line of data can be read from the device; otherwise returns false.
 
void startTransaction ()
 
void commitTransaction ()
 
void rollbackTransaction ()
 
bool isTransactionStarted () const
 
qint64 write (const char *data, qint64 len)
 Writes at most maxSize bytes of data from data to the device.
 
qint64 write (const char *data)
 
qint64 write (const QByteArray &data)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes the content of data to the device.
 
qint64 peek (char *data, qint64 maxlen)
 
QByteArray peek (qint64 maxlen)
 
qint64 skip (qint64 maxSize)
 
virtual bool waitForReadyRead (int msecs)
 Blocks until new data is available for reading and the readyRead() signal has been emitted, or until msecs milliseconds have passed.
 
virtual bool waitForBytesWritten (int msecs)
 For buffered devices, this function waits until a payload of buffered written data has been written to the device and the bytesWritten() signal has been emitted, or until msecs milliseconds have passed.
 
void ungetChar (char c)
 Puts the character c back into the device, and decrements the current position unless the position is 0.
 
bool putChar (char c)
 Writes the character c to the device.
 
bool getChar (char *c)
 Reads one character from the device and stores it in c.
 
QString errorString () const
 Returns a human-readable description of the last device error that occurred.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
template<typename T >
findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Protected Member Functions

void connectNotify (const QMetaMethod &) override
 \reimp
 
void disconnectNotify (const QMetaMethod &) override
 \reimp
 
qint64 readData (char *data, qint64 maxlen) override
 \reimp
 
qint64 writeData (const char *data, qint64 len) override
 \reimp
 
- Protected Member Functions inherited from QIODevice
 QIODevice (QIODevicePrivate &dd, QObject *parent=nullptr)
 
virtual qint64 readData (char *data, qint64 maxlen)=0
 Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an error occurred.
 
virtual qint64 readLineData (char *data, qint64 maxlen)
 Reads up to maxSize characters into data and returns the number of characters read.
 
virtual qint64 skipData (qint64 maxSize)
 
virtual qint64 writeData (const char *data, qint64 len)=0
 Writes up to maxSize bytes from data to the device.
 
void setOpenMode (QIODeviceBase::OpenMode openMode)
 Sets the OpenMode of the device to openMode.
 
void setErrorString (const QString &errorString)
 Sets the human readable description of the last device error that occurred to str.
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QIODeviceBase
 ~QIODeviceBase ()=default
 

Additional Inherited Members

- Public Types inherited from QIODeviceBase
enum  OpenModeFlag {
  NotOpen = 0x0000 , ReadOnly = 0x0001 , WriteOnly = 0x0002 , ReadWrite = ReadOnly | WriteOnly ,
  Append = 0x0004 , Truncate = 0x0008 , Text = 0x0010 , Unbuffered = 0x0020 ,
  NewOnly = 0x0040 , ExistingOnly = 0x0080
}
 This enum is used with QIODevice::open() to describe the mode in which a device is opened. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Signals inherited from QIODevice
void readyRead ()
 This signal is emitted once every time new data is available for reading from the device's current read channel.
 
void channelReadyRead (int channel)
 
void bytesWritten (qint64 bytes)
 This signal is emitted every time a payload of data has been written to the device's current write channel.
 
void channelBytesWritten (int channel, qint64 bytes)
 
void aboutToClose ()
 This signal is emitted when the device is about to close.
 
void readChannelFinished ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

\inmodule QtCore \reentrant

The QBuffer class provides a QIODevice interface for a QByteArray.

QBuffer allows you to access a QByteArray using the QIODevice interface. The QByteArray is treated just as a standard random-accessed file. Example:

char ch;
buffer.write("Qt rocks!");
buffer.seek(0);
buffer.getChar(&ch); // ch == 'Q'
buffer.getChar(&ch); // ch == 't'
buffer.getChar(&ch); // ch == ' '
buffer.getChar(&ch); // ch == 'r'
\inmodule QtCore \reentrant
Definition qbuffer.h:16
QByteArray & buffer()
Returns a reference to the QBuffer's internal buffer.
Definition qbuffer.cpp:218
GLenum GLuint buffer

By default, an internal QByteArray buffer is created for you when you create a QBuffer. You can access this buffer directly by calling buffer(). You can also use QBuffer with an existing QByteArray by calling setBuffer(), or by passing your array to QBuffer's constructor.

Call open() to open the buffer. Then call write() or putChar() to write to the buffer, and read(), readLine(), readAll(), or getChar() to read from it. size() returns the current size of the buffer, and you can seek to arbitrary positions in the buffer by calling seek(). When you are done with accessing the buffer, call close().

The following code snippet shows how to write data to a QByteArray using QDataStream and QBuffer:

QByteArray byteArray;
QBuffer buffer(&byteArray);
static QPalette palette()
Returns the current application palette.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatastream.h:30
QTextStream out(stdout)
[7]

Effectively, we convert the application's QPalette into a byte array. Here's how to read the data from the QByteArray:

QBuffer buffer(&byteArray);
in >> palette;
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
GLuint in

QTextStream and QDataStream also provide convenience constructors that take a QByteArray and that create a QBuffer behind the scenes.

QBuffer emits readyRead() when new data has arrived in the buffer. By connecting to this signal, you can use QBuffer to store temporary data before processing it. QBuffer also emits bytesWritten() every time new data has been written to the buffer.

See also
QFile, QDataStream, QTextStream, QByteArray

Definition at line 15 of file qbuffer.h.

Constructor & Destructor Documentation

◆ QBuffer() [1/2]

QBuffer::QBuffer ( QObject parent = nullptr)
explicit

Constructs an empty buffer with the given parent.

You can call setData() to fill the buffer with data, or you can open it in write mode and use write().

See also
open()

Definition at line 133 of file qbuffer.cpp.

References d.

◆ QBuffer() [2/2]

QBuffer::QBuffer ( QByteArray byteArray,
QObject parent = nullptr 
)

Constructs a QBuffer that uses the QByteArray pointed to by byteArray as its internal buffer, and with the given parent.

The caller is responsible for ensuring that byteArray remains valid until the QBuffer is destroyed, or until setBuffer() is called to change the buffer. QBuffer doesn't take ownership of the QByteArray.

If you open the buffer in write-only mode or read-write mode and write something into the QBuffer, byteArray will be modified.

Example:

QByteArray byteArray("abc");
QBuffer buffer(&byteArray);
buffer.seek(3);
buffer.write("def", 3);
buffer.close();
// byteArray == "abcdef"
See also
open(), setBuffer(), setData()

Definition at line 157 of file qbuffer.cpp.

References d.

◆ ~QBuffer()

QBuffer::~QBuffer ( )

Destroys the buffer.

Definition at line 170 of file qbuffer.cpp.

Member Function Documentation

◆ atEnd()

bool QBuffer::atEnd ( ) const
overridevirtual

\reimp

Reimplemented from QIODevice.

Definition at line 365 of file qbuffer.cpp.

References QIODevice::atEnd().

+ Here is the call graph for this function:

◆ buffer() [1/2]

QByteArray & QBuffer::buffer ( )

Returns a reference to the QBuffer's internal buffer.

You can use it to modify the QByteArray behind the QBuffer's back.

See also
setBuffer(), data()

Definition at line 218 of file qbuffer.cpp.

References d.

Referenced by QPicturePrivate::checkFormat(), and QQmlPreviewFileEngine::setSize().

+ Here is the caller graph for this function:

◆ buffer() [2/2]

const QByteArray & QBuffer::buffer ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This is the same as data().

Definition at line 230 of file qbuffer.cpp.

References d.

◆ canReadLine()

bool QBuffer::canReadLine ( ) const
overridevirtual

\reimp

Reimplemented from QIODevice.

Definition at line 373 of file qbuffer.cpp.

References QIODevice::canReadLine(), d, QIODevice::isOpen(), and pos().

+ Here is the call graph for this function:

◆ close()

void QBuffer::close ( )
overridevirtual

\reimp

Reimplemented from QIODevice.

Definition at line 316 of file qbuffer.cpp.

References QIODevice::close().

Referenced by QZipStreamStrategy::~QZipStreamStrategy(), QPicturePrivate::checkFormat(), QPdfDocumentPrivate::clear(), QQmlPreviewFileEngine::close(), QQmlPreviewFileEngine::setFileName(), QAndroidAudioSource::start(), and QAndroidAudioSource::start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ connectNotify()

void QBuffer::connectNotify ( const QMetaMethod signal)
overrideprotectedvirtual

\reimp

Reimplemented from QObject.

Definition at line 438 of file qbuffer.cpp.

References is_tracked_signal(), and signal.

+ Here is the call graph for this function:

◆ data()

const QByteArray & QBuffer::data ( ) const

Returns the data contained in the buffer.

This is the same as buffer().

See also
setData(), setBuffer()

Definition at line 245 of file qbuffer.cpp.

References d.

Referenced by QTextOdfWriter::writeInlineCharacter().

+ Here is the caller graph for this function:

◆ disconnectNotify()

void QBuffer::disconnectNotify ( const QMetaMethod signal)
overrideprotectedvirtual

\reimp

Reimplemented from QObject.

Definition at line 448 of file qbuffer.cpp.

References is_tracked_signal(), and signal.

+ Here is the call graph for this function:

◆ open()

bool QBuffer::open ( OpenMode  flags)
override

\reimp

Unlike QFile, opening a QBuffer QIODevice::WriteOnly does not truncate it. However, pos() is set to 0. Use QIODevice::Append or QIODevice::Truncate to change either behavior.

Definition at line 296 of file qbuffer.cpp.

References QIODeviceBase::Append, d, QIODevice::open(), qWarning, QIODeviceBase::ReadOnly, QIODeviceBase::Truncate, QIODeviceBase::Unbuffered, and QIODeviceBase::WriteOnly.

Referenced by QPdfDocumentPrivate::QPdfDocumentPrivate(), QPicturePrivate::QPicturePrivate(), QZipStreamStrategy::QZipStreamStrategy(), QPicturePrivate::checkFormat(), QPdfDocumentPrivate::clear(), FinalWidget::mouseMoveEvent(), QQmlPreviewFileEngine::open(), and QAndroidAudioSource::start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pos()

qint64 QBuffer::pos ( ) const
overridevirtual

\reimp

Reimplemented from QIODevice.

Definition at line 324 of file qbuffer.cpp.

References QIODevice::pos().

Referenced by canReadLine(), QQmlPreviewFileEngine::pos(), readData(), seek(), and writeData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readData()

qint64 QBuffer::readData ( char *  data,
qint64  maxlen 
)
overrideprotectedvirtual

\reimp

Implements QIODevice.

Definition at line 385 of file qbuffer.cpp.

References d, pos(), and qMin().

+ Here is the call graph for this function:

◆ seek()

bool QBuffer::seek ( qint64  off)
overridevirtual

\reimp

Reimplemented from QIODevice.

Definition at line 341 of file qbuffer.cpp.

References d, QIODevice::isWritable(), pos(), QT_CATCH, QT_TRY, qWarning, and QIODevice::seek().

Referenced by QPicturePrivate::QPicturePrivate(), QPdfDocumentPrivate::_q_copyFromSequentialSourceDevice(), and QQmlPreviewFileEngine::seek().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBuffer()

void QBuffer::setBuffer ( QByteArray byteArray)

Makes QBuffer use the QByteArray pointed to by byteArray as its internal buffer.

The caller is responsible for ensuring that byteArray remains valid until the QBuffer is destroyed, or until setBuffer() is called to change the buffer. QBuffer doesn't take ownership of the QByteArray.

Does nothing if isOpen() is true.

If you open the buffer in write-only mode or read-write mode and write something into the QBuffer, byteArray will be modified.

Example:

QByteArray byteArray("abc");
buffer.setBuffer(&byteArray);
buffer.seek(3);
buffer.write("def", 3);
buffer.close();
// byteArray == "abcdef"

If byteArray is \nullptr, the buffer creates its own internal QByteArray to work on. This byte array is initially empty.

See also
buffer(), setData(), open()

Definition at line 196 of file qbuffer.cpp.

References d, QIODevice::isOpen(), and qWarning.

+ Here is the call graph for this function:

◆ setData() [1/2]

void QBuffer::setData ( const char *  data,
qsizetype  size 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the contents of the internal buffer to be the first size bytes of data.

Note
In Qt versions prior to 6.5, this function took the length as an {int} parameter, potentially truncating sizes.

Definition at line 278 of file qbuffer.cpp.

References d, QIODevice::isOpen(), and qWarning.

+ Here is the call graph for this function:

◆ setData() [2/2]

void QBuffer::setData ( const QByteArray data)

Sets the contents of the internal buffer to be data.

This is the same as assigning data to buffer().

Does nothing if isOpen() is true.

See also
setBuffer()

Definition at line 259 of file qbuffer.cpp.

References d, QIODevice::isOpen(), and qWarning.

Referenced by QPdfDocumentPrivate::QPdfDocumentPrivate(), QPicturePrivate::QPicturePrivate(), QPdfDocumentPrivate::clear(), QNetworkAccessManager::post(), QNetworkAccessManager::put(), QNetworkAccessManager::sendCustomRequest(), and QQmlPreviewFileEngine::setFileName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

qint64 QBuffer::size ( ) const
overridevirtual

\reimp

Reimplemented from QIODevice.

Definition at line 332 of file qbuffer.cpp.

References d.

Referenced by QPdfDocumentPrivate::_q_copyFromSequentialSourceDevice(), QPicturePrivate::checkFormat(), and QQmlPreviewFileEngine::size().

+ Here is the caller graph for this function:

◆ writeData()

qint64 QBuffer::writeData ( const char *  data,
qint64  len 
)
overrideprotectedvirtual

\reimp

Implements QIODevice.

Definition at line 397 of file qbuffer.cpp.

References d, QMetaObject::invokeMethod(), pos(), Qt::QueuedConnection, qWarning, and QObject::signalsBlocked().

+ Here is the call graph for this function:

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