Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 538

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QBuffer Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QBuffer Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QBuffer class provides a <a href="qiodevice.html">QIODevice</a> interface for a <a href="qbytearray.html">QByteArray</a>. <a href="#details">More...</a></p>

<p>Inherits <a href="qiodevice.html">QIODevice</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qbuffer.html#QBuffer">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qbuffer.html#QBuffer-2">__init__</a></b> (<i>self</i>, QByteArray&#160;<i>byteArray</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qbuffer.html#atEnd">atEnd</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qbuffer.html#buffer">buffer</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qbuffer.html#canReadLine">canReadLine</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbuffer.html#close">close</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbuffer.html#connectNotify">connectNotify</a></b> (<i>self</i>, SIGNAL())</li><li><div class="fn" />QByteArray <b><a href="qbuffer.html#data">data</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbuffer.html#disconnectNotify">disconnectNotify</a></b> (<i>self</i>, SIGNAL())</li><li><div class="fn" />bool <b><a href="qbuffer.html#open">open</a></b> (<i>self</i>, QIODevice.OpenMode&#160;<i>openMode</i>)</li><li><div class="fn" />int <b><a href="qbuffer.html#pos">pos</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qbuffer.html#readData">readData</a></b> (<i>self</i>, int&#160;<i>maxlen</i>)</li><li><div class="fn" />bool <b><a href="qbuffer.html#seek">seek</a></b> (<i>self</i>, int&#160;<i>off</i>)</li><li><div class="fn" /><b><a href="qbuffer.html#setBuffer">setBuffer</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" /><b><a href="qbuffer.html#setData">setData</a></b> (<i>self</i>, QByteArray&#160;<i>data</i>)</li><li><div class="fn" /><b><a href="qbuffer.html#setData-2">setData</a></b> (<i>self</i>, str&#160;<i>adata</i>)</li><li><div class="fn" />int <b><a href="qbuffer.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qbuffer.html#writeData">writeData</a></b> (<i>self</i>, str&#160;<i>data</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QBuffer class provides a <a href="qiodevice.html">QIODevice</a> interface for a <a href="qbytearray.html">QByteArray</a>.</p>
<p>QBuffer allows you to access a <a href="qbytearray.html">QByteArray</a> using the <a href="qiodevice.html">QIODevice</a> interface. The <a href="qbytearray.html">QByteArray</a> is treated just as a standard
random-accessed file. Example:</p>
<pre class="cpp">
     <span class="type">QBuffer</span> buffer;
     <span class="type">char</span> ch;

     buffer<span class="operator">.</span>open(<span class="type">QBuffer</span><span class="operator">.</span>ReadWrite);
     buffer<span class="operator">.</span>write(<span class="string">"Qt rocks!"</span>);
     buffer<span class="operator">.</span>seek(<span class="number">0</span>);
     buffer<span class="operator">.</span>getChar(<span class="operator">&amp;</span>ch);  <span class="comment">// ch == 'Q'</span>
     buffer<span class="operator">.</span>getChar(<span class="operator">&amp;</span>ch);  <span class="comment">// ch == 't'</span>
     buffer<span class="operator">.</span>getChar(<span class="operator">&amp;</span>ch);  <span class="comment">// ch == ' '</span>
     buffer<span class="operator">.</span>getChar(<span class="operator">&amp;</span>ch);  <span class="comment">// ch == 'r'</span>
</pre>
<p>By default, an internal <a href="qbytearray.html">QByteArray</a>
buffer is created for you when you create a QBuffer. You can access
this buffer directly by calling <a href="qbuffer.html#buffer">buffer</a>(). You can also use QBuffer with
an existing <a href="qbytearray.html">QByteArray</a> by calling
<a href="qbuffer.html#setBuffer">setBuffer</a>(), or by passing
your array to QBuffer's constructor.</p>
<p>Call <a href="qbuffer.html#open">open</a>() to open the buffer.
Then call <a href="qiodevice.html#write">write</a>() or <a href="qiodevice.html#putChar">putChar</a>() to write to the buffer, and
<a href="qiodevice.html#read">read</a>(), <a href="qiodevice.html#readLine">readLine</a>(), <a href="qiodevice.html#readAll">readAll</a>(), or <a href="qiodevice.html#getChar">getChar</a>() to read from it. <a href="qbuffer.html#size">size</a>() returns the current size of the
buffer, and you can seek to arbitrary positions in the buffer by
calling <a href="qbuffer.html#seek">seek</a>(). When you are done
with accessing the buffer, call <a href="qbuffer.html#close">close</a>().</p>
<p>The following code snippet shows how to write data to a <a href="qbytearray.html">QByteArray</a> using <a href="qdatastream.html">QDataStream</a> and QBuffer:</p>
<pre class="cpp">
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> byteArray;
     <span class="type">QBuffer</span> buffer(<span class="operator">&amp;</span>byteArray);
     buffer<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">.</span>WriteOnly);

     <span class="type"><a href="qdatastream.html">QDataStream</a></span> out(<span class="operator">&amp;</span>buffer);
     out <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>palette();
</pre>
<p>Effectively, we convert the application's <a href="qpalette.html">QPalette</a> into a byte array. Here's how to read
the data from the <a href="qbytearray.html">QByteArray</a>:</p>
<pre class="cpp">
     <span class="type"><a href="qpalette.html">QPalette</a></span> palette;
     <span class="type">QBuffer</span> buffer(<span class="operator">&amp;</span>byteArray);
     buffer<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">.</span>ReadOnly);

     <span class="type"><a href="qdatastream.html">QDataStream</a></span> in(<span class="operator">&amp;</span>buffer);
     in <span class="operator">&gt;</span><span class="operator">&gt;</span> palette;
</pre>
<p><a href="qtextstream.html">QTextStream</a> and <a href="qdatastream.html">QDataStream</a> also provide convenience
constructors that take a <a href="qbytearray.html">QByteArray</a>
and that create a QBuffer behind the scenes.</p>
<p>QBuffer emits <a href="qiodevice.html#readyRead">readyRead</a>()
when new data has arrived in the buffer. By connecting to this
signal, you can use QBuffer to store temporary data before
processing it. For example, you can pass the buffer to <a href="qftp.html">QFtp</a> when downloading a file from an FTP server.
Whenever a new payload of data has been downloaded, <a href="qiodevice.html#readyRead">readyRead</a>() is emitted, and you can
process the data that just arrived. QBuffer also emits <a href="qiodevice.html#bytesWritten">bytesWritten</a>() every time new
data has been written to the buffer.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QBuffer" />QBuffer.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an empty buffer with the given <i>parent</i>. You can
call <a href="qbuffer.html#setData">setData</a>() to fill the
buffer with data, or you can open it in write mode and use <a href="qiodevice.html#write">write</a>().</p>
<p><b>See also</b> <a href="qbuffer.html#open">open</a>().</p>


<h3 class="fn"><a name="QBuffer-2" />QBuffer.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>byteArray</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qbuffer.html">QBuffer</a> that uses the
<a href="qbytearray.html">QByteArray</a> pointed to by
<i>byteArray</i> as its internal buffer, and with the given
<i>parent</i>. The caller is responsible for ensuring that
<i>byteArray</i> remains valid until the <a href="qbuffer.html">QBuffer</a> is destroyed, or until <a href="qbuffer.html#setBuffer">setBuffer</a>() is called to change the
buffer. <a href="qbuffer.html">QBuffer</a> doesn't take ownership
of the <a href="qbytearray.html">QByteArray</a>.</p>
<p>If you open the buffer in write-only mode or read-write mode and
write something into the <a href="qbuffer.html">QBuffer</a>,
<i>byteArray</i> will be modified.</p>
<p>Example:</p>
<pre class="cpp">
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> byteArray(<span class="string">"abc"</span>);
     <span class="type"><a href="qbuffer.html">QBuffer</a></span> buffer(<span class="operator">&amp;</span>byteArray);
     buffer<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">.</span>WriteOnly);
     buffer<span class="operator">.</span>seek(<span class="number">3</span>);
     buffer<span class="operator">.</span>write(<span class="string">"def"</span><span class="operator">,</span> <span class="number">3</span>);
     buffer<span class="operator">.</span>close();
     <span class="comment">// byteArray == "abcdef"</span>
</pre>
<p><b>See also</b> <a href="qbuffer.html#open">open</a>(), <a href="qbuffer.html#setBuffer">setBuffer</a>(), and <a href="qbuffer.html#setData">setData</a>().</p>


<h3 class="fn"><a name="atEnd" />bool QBuffer.atEnd (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#atEnd">QIODevice.atEnd</a>().</p>


<h3 class="fn"><a name="buffer" /><a href="qbytearray.html">QByteArray</a> QBuffer.buffer (<i>self</i>)</h3><p>Returns a reference to the <a href="qbuffer.html">QBuffer</a>'s
internal buffer. You can use it to modify the <a href="qbytearray.html">QByteArray</a> behind the <a href="qbuffer.html">QBuffer</a>'s back.</p>
<p><b>See also</b> <a href="qbuffer.html#setBuffer">setBuffer</a>()
and <a href="qbuffer.html#data">data</a>().</p>


<h3 class="fn"><a name="canReadLine" />bool QBuffer.canReadLine (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#canReadLine">QIODevice.canReadLine</a>().</p>


<h3 class="fn"><a name="close" />QBuffer.close (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#close">QIODevice.close</a>().</p>


<h3 class="fn"><a name="connectNotify" />QBuffer.connectNotify (<i>self</i>, SIGNAL())</h3><h3 class="fn"><a name="data" /><a href="qbytearray.html">QByteArray</a> QBuffer.data (<i>self</i>)</h3><p>Returns the data contained in the buffer.</p>
<p>This is the same as <a href="qbuffer.html#buffer">buffer</a>().</p>
<p><b>See also</b> <a href="qbuffer.html#setData">setData</a>() and
<a href="qbuffer.html#setBuffer">setBuffer</a>().</p>


<h3 class="fn"><a name="disconnectNotify" />QBuffer.disconnectNotify (<i>self</i>, SIGNAL())</h3><h3 class="fn"><a name="open" />bool QBuffer.open (<i>self</i>, <a href="qiodevice-openmode.html">QIODevice.OpenMode</a>&#160;<i>openMode</i>)</h3><p>Reimplemented from <a href="qiodevice.html#open">QIODevice.open</a>().</p>


<h3 class="fn"><a name="pos" />int QBuffer.pos (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#pos">QIODevice.pos</a>().</p>


<h3 class="fn"><a name="readData" />str QBuffer.readData (<i>self</i>, int&#160;<i>maxlen</i>)</h3><p>Reimplemented from <a href="qiodevice.html#readData">QIODevice.readData</a>().</p>


<h3 class="fn"><a name="seek" />bool QBuffer.seek (<i>self</i>, int&#160;<i>off</i>)</h3><p>Reimplemented from <a href="qiodevice.html#seek">QIODevice.seek</a>().</p>


<h3 class="fn"><a name="setBuffer" />QBuffer.setBuffer (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Makes <a href="qbuffer.html">QBuffer</a> uses the <a href="qbytearray.html">QByteArray</a> pointed to by <i>byteArray</i> as
its internal buffer. The caller is responsible for ensuring that
<i>byteArray</i> remains valid until the <a href="qbuffer.html">QBuffer</a> is destroyed, or until setBuffer() is
called to change the buffer. <a href="qbuffer.html">QBuffer</a>
doesn't take ownership of the <a href="qbytearray.html">QByteArray</a>.</p>
<p>Does nothing if <a href="qiodevice.html#isOpen">isOpen</a>() is
true.</p>
<p>If you open the buffer in write-only mode or read-write mode and
write something into the <a href="qbuffer.html">QBuffer</a>,
<i>byteArray</i> will be modified.</p>
<p>Example:</p>
<pre class="cpp">
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> byteArray(<span class="string">"abc"</span>);
     <span class="type"><a href="qbuffer.html">QBuffer</a></span> buffer;
     buffer<span class="operator">.</span>setBuffer(<span class="operator">&amp;</span>byteArray);
     buffer<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">.</span>WriteOnly);
     buffer<span class="operator">.</span>seek(<span class="number">3</span>);
     buffer<span class="operator">.</span>write(<span class="string">"def"</span><span class="operator">,</span> <span class="number">3</span>);
     buffer<span class="operator">.</span>close();
     <span class="comment">// byteArray == "abcdef"</span>
</pre>
<p>If <i>byteArray</i> is 0, the buffer creates its own internal
<a href="qbytearray.html">QByteArray</a> to work on. This byte
array is initially empty.</p>
<p><b>See also</b> <a href="qbuffer.html#buffer">buffer</a>(),
<a href="qbuffer.html#setData">setData</a>(), and <a href="qbuffer.html#open">open</a>().</p>


<h3 class="fn"><a name="setData" />QBuffer.setData (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>data</i>)</h3><p>Sets the contents of the internal buffer to be <i>data</i>. This
is the same as assigning <i>data</i> to <a href="qbuffer.html#buffer">buffer</a>().</p>
<p>Does nothing if <a href="qiodevice.html#isOpen">isOpen</a>() is
true.</p>
<p><b>See also</b> <a href="qbuffer.html#data">data</a>() and
<a href="qbuffer.html#setBuffer">setBuffer</a>().</p>


<h3 class="fn"><a name="setData-2" />QBuffer.setData (<i>self</i>, str&#160;<i>adata</i>)</h3><p>This is an overloaded function.</p>
<p>Sets the contents of the internal buffer to be the first
<i>size</i> bytes of <i>data</i>.</p>


<h3 class="fn"><a name="size" />int QBuffer.size (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#size">QIODevice.size</a>().</p>


<h3 class="fn"><a name="writeData" />int QBuffer.writeData (<i>self</i>, str&#160;<i>data</i>)</h3><p>Reimplemented from <a href="qiodevice.html#writeData">QIODevice.writeData</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>