File: qbytearray.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (502 lines) | stat: -rw-r--r-- 68,098 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<?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>QByteArray 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="../pyqt4ref.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">QByteArray Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QByteArray class provides an array of bytes. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qbytearray.html#QByteArray">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#QByteArray-2">__init__</a></b> (<i>self</i>, int&#160;<i>size</i>, char&#160;<i>c</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#QByteArray-3">__init__</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#append">append</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#append-2">append</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />char <b><a href="qbytearray.html#at">at</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#capacity">capacity</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#chop">chop</a></b> (<i>self</i>, int&#160;<i>n</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#contains">contains</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#count">count</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#count-2">count</a></b> (<i>self</i>)</li><li><div class="fn" />object <b><a href="qbytearray.html#data">data</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#endsWith">endsWith</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#fill">fill</a></b> (<i>self</i>, char&#160;<i>c</i>, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qbytearray.html#indexOf">indexOf</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>, int&#160;<i>from</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qbytearray.html#indexOf-2">indexOf</a></b> (<i>self</i>, QString&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;0)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#insert">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#insert-2">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#lastIndexOf">lastIndexOf</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>, int&#160;<i>from</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qbytearray.html#lastIndexOf-2">lastIndexOf</a></b> (<i>self</i>, QString&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;-1)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#left">left</a></b> (<i>self</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#leftJustified">leftJustified</a></b> (<i>self</i>, int&#160;<i>width</i>, char&#160;<i>fill</i>&#160;=&#160;' ', bool&#160;<i>truncate</i>&#160;=&#160;False)</li><li><div class="fn" />int <b><a href="qbytearray.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#mid">mid</a></b> (<i>self</i>, int&#160;<i>index</i>, int&#160;<i>len</i>&#160;=&#160;-1)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#prepend">prepend</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#push_back">push_back</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#push_front">push_front</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#remove">remove</a></b> (<i>self</i>, int&#160;<i>index</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#replace">replace</a></b> (<i>self</i>, int&#160;<i>index</i>, int&#160;<i>len</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#replace-2">replace</a></b> (<i>self</i>, QByteArray&#160;<i>before</i>, QByteArray&#160;<i>after</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#replace-3">replace</a></b> (<i>self</i>, QString&#160;<i>before</i>, QByteArray&#160;<i>after</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#reserve">reserve</a></b> (<i>self</i>, int&#160;<i>size</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#resize">resize</a></b> (<i>self</i>, int&#160;<i>size</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#right">right</a></b> (<i>self</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#rightJustified">rightJustified</a></b> (<i>self</i>, int&#160;<i>width</i>, char&#160;<i>fill</i>&#160;=&#160;' ', bool&#160;<i>truncate</i>&#160;=&#160;False)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#setNum">setNum</a></b> (<i>self</i>, int&#160;<i>n</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#setNum-2">setNum</a></b> (<i>self</i>, float, char&#160;<i>f</i>&#160;=&#160;'g', int&#160;<i>prec</i>&#160;=&#160;6)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#setNum-3">setNum</a></b> (<i>self</i>, long, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#setNum-4">setNum</a></b> (<i>self</i>, unsigned long, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#simplified">simplified</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray-list <b><a href="qbytearray.html#split">split</a></b> (<i>self</i>, char&#160;<i>sep</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#squeeze">squeeze</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#startsWith">startsWith</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#toBase64">toBase64</a></b> (<i>self</i>)</li><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toDouble">toDouble</a></b> (<i>self</i>)</li><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toFloat">toFloat</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toInt">toInt</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(long, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toLong">toLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(long, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toLongLong">toLongLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#toLower">toLower</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toShort">toShort</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(unsigned long, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toUInt">toUInt</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(unsigned long, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toULong">toULong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(unsigned long, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toULongLong">toULongLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#toUpper">toUpper</a></b> (<i>self</i>)</li><li><div class="fn" />(unsigned long, bool&#160;<i>ok</i>) <b><a href="qbytearray.html#toUShort">toUShort</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#trimmed">trimmed</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbytearray.html#truncate">truncate</a></b> (<i>self</i>, int&#160;<i>pos</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QByteArray <b><a href="qbytearray.html#fromBase64">fromBase64</a></b> (QByteArray&#160;<i>base64</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#fromRawData">fromRawData</a></b> (str)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#number">number</a></b> (int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#number-2">number</a></b> (float, char&#160;<i>f</i>&#160;=&#160;'g', int&#160;<i>prec</i>&#160;=&#160;6)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#number-3">number</a></b> (long, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#number-4">number</a></b> (unsigned long, int&#160;<i>base</i>&#160;=&#160;10)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QString <b><a href="qbytearray.html#__add__">__add__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#__add__-2">__add__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#__contains__">__contains__</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__eq__">__eq__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__eq__-2">__eq__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__ge__">__ge__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__ge__-2">__ge__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />char <b><a href="qbytearray.html#__getitem__">__getitem__</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#__getitem__-2">__getitem__</a></b> (<i>self</i>, slice&#160;<i>slice</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__gt__">__gt__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__gt__-2">__gt__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />long <b><a href="qbytearray.html#__hash__">__hash__</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#__iadd__">__iadd__</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#__iadd__-2">__iadd__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#__imul__">__imul__</a></b> (<i>self</i>, int&#160;<i>m</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__le__">__le__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__le__-2">__le__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />int <b><a href="qbytearray.html#__len__">__len__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__lt__">__lt__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__lt__-2">__lt__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />QByteArray <b><a href="qbytearray.html#__mul__">__mul__</a></b> (<i>self</i>, int&#160;<i>m</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__ne__">__ne__</a></b> (<i>self</i>, QByteArray&#160;<i>a2</i>)</li><li><div class="fn" />bool <b><a href="qbytearray.html#__ne__-2">__ne__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />object <b><a href="qbytearray.html#__str__">__str__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>A Python string object
    may be used whenever a
    <a href="qbytearray.html">QByteArray</a>
    is expected.</p>
  <p>The QByteArray class provides an array of bytes.</p>
<p>QByteArray can be used to store both raw bytes (including '\0's) and traditional 8-bit '\0'-terminated strings. Using QByteArray is much more convenient than using <tt>const char *</tt>. Behind the scenes, it always ensures that the data is followed by a '\0' terminator, and uses <a href="shclass.html#implicit-sharing">implicit sharing</a> (copy-on-write) to reduce memory usage and avoid needless copying of data.</p>
<p>In addition to QByteArray, Qt also provides the <a href="qstring.html">QString</a> class to store string data. For most purposes, <a href="qstring.html">QString</a> is the class you want to use. It stores 16-bit Unicode characters, making it easy to store non-ASCII/non-Latin-1 characters in your application. Furthermore, <a href="qstring.html">QString</a> is used throughout in the Qt API. The two main cases where QByteArray is appropriate are when you need to store raw binary data, and when memory conservation is critical (e.g. with Qtopia Core).</p>
<p>One way to initialize a QByteArray is simply to pass a <tt>const char *</tt> to its constructor. For example, the following code creates a byte array of size 5 containing the data "Hello":</p>
<pre>
    QByteArray ba("Hello");
</pre>
<p>Although the <a href="qbytearray.html#size">size</a>() is 5, the byte array also maintains an extra '\0' character at the end so that if a function is used that asks for a pointer to the underlying data (e.g. a call to <a href="qbytearray.html#data">data</a>()), the data pointed to is guaranteed to be '\0'-terminated.</p>
<p>QByteArray makes a deep copy of the <tt>const char *</tt> data, so you can modify it later without experiencing side effects. (If for performance reasons you don't want to take a deep copy of the character data, use <a href="qbytearray.html#fromRawData">QByteArray.fromRawData</a>() instead.)</p>
<p>Another approach is to set the size of the array using <a href="qbytearray.html#resize">resize</a>() and to initialize the data byte per byte. QByteArray uses 0-based indexes, just like C++ arrays. To access the byte at a particular index position, you can use operator[](). On non-const byte arrays, operator[]() returns a reference to a byte that can be used on the left side of an assignment. For example:</p>
<pre>
    QByteArray ba;
    ba.resize(5);
    ba[0] = 0x3c;
    ba[1] = 0xb8;
    ba[2] = 0x64;
    ba[3] = 0x18;
    ba[4] = 0xca;
</pre>
<p>For read-only access, an alternative syntax is to use <a href="qbytearray.html#at">at</a>():</p>
<pre>
    for (int i = 0; i &lt; ba.size(); ++i) {
        if (ba.at(i) &gt;= 'a' &amp;&amp; ba.at(i) &lt;= 'f')
            cout &lt;&lt; "Found character in range [a-f]" &lt;&lt; endl;
    }
</pre>
<p><a href="qbytearray.html#at">at</a>() can be faster than operator[](), because it never causes a <a href="shclass.html#deep-copy">deep copy</a> to occur.</p>
<p>To extract many bytes at a time, use <a href="qbytearray.html#left">left</a>(), <a href="qbytearray.html#right">right</a>(), or <a href="qbytearray.html#mid">mid</a>().</p>
<p>A QByteArray can embed '\0' bytes. The <a href="qbytearray.html#size">size</a>() function always returns the size of the whole array, including embedded '\0' bytes. If you want to obtain the length of the data up to and excluding the first '\0' character, call <a href="qtcore.html#qstrlen">qstrlen</a>() on the byte array.</p>
<p>After a call to <a href="qbytearray.html#resize">resize</a>(), newly allocated bytes have undefined values. To set all the bytes to a particular value, call <a href="qbytearray.html#fill">fill</a>().</p>
<p>To obtain a pointer to the actual character data, call <a href="qbytearray.html#data">data</a>() or <a href="qbytearray.html#constData">constData</a>(). These functions return a pointer to the beginning of the data. The pointer is guaranteed to remain valid until a non-const function is called on the QByteArray. It is also guaranteed that the data ends with a '\0' byte. This '\0' byte is automatically provided by QByteArray and is not counted in <a href="qbytearray.html#size">size</a>().</p>
<p>QByteArray provides the following basic functions for modifying the byte data: <a href="qbytearray.html#append">append</a>(), <a href="qbytearray.html#prepend">prepend</a>(), <a href="qbytearray.html#insert">insert</a>(), <a href="qbytearray.html#replace">replace</a>(), and <a href="qbytearray.html#remove">remove</a>(). For example:</p>
<pre>
    QByteArray x("and");
    x.prepend("rock ");         // x == "rock and"
    x.append(" roll");          // x == "rock and roll"
    x.replace(5, 3, "&amp;");       // x == "rock &amp; roll"
</pre>
<p>The <a href="qbytearray.html#replace">replace</a>() and <a href="qbytearray.html#remove">remove</a>() functions' first two arguments are the position from which to start erasing and the number of bytes that should be erased.</p>
<p>If you are building a QByteArray gradually and know in advance approximately how many bytes the QByteArray will contain, you can call <a href="qbytearray.html#reserve">reserve</a>(), asking QByteArray to preallocate a certain amount of memory. You can also call <a href="qbytearray.html#capacity">capacity</a>() to find out how much memory QByteArray actually allocated.</p>
<p>A frequent requirement is to remove whitespace characters from a byte array ('\n', '\t', ' ', etc.). If you want to remove whitespace from both ends of a QByteArray, use <a href="qbytearray.html#trimmed">trimmed</a>(). If you want to remove whitespace from both ends and replace multiple consecutive whitespaces with a single space character within the byte array, use <a href="qbytearray.html#simplified">simplified</a>().</p>
<p>If you want to find all occurrences of a particular character or substring in a QByteArray, use <a href="qbytearray.html#indexOf">indexOf</a>() or <a href="qbytearray.html#lastIndexOf">lastIndexOf</a>(). The former searches forward starting from a given index position, the latter searches backward. Both return the index position of the character or substring if they find it; otherwise, they return -1. For example, here's a typical loop that finds all occurrences of a particular substring:</p>
<pre>
    QByteArray ba("We must be &lt;b&gt;bold&lt;/b&gt;, very &lt;b&gt;bold&lt;/b&gt;");
    int j = 0;
    while ((j = ba.indexOf("&lt;b&gt;", j)) != -1) {
        cout &lt;&lt; "Found &lt;b&gt; tag at index position " &lt;&lt; j &lt;&lt; endl;
        ++j;
    }
</pre>
<p>If you simply want to check whether a QByteArray contains a particular character or substring, use <a href="qbytearray.html#contains">contains</a>(). If you want to find out how many times a particular character or substring occurs in the byte array, use <a href="qbytearray.html#count">count</a>(). If you want to replace all occurrences of a particular value with another, use one of the two-parameter <a href="qbytearray.html#replace">replace</a>() overloads.</p>
<p>QByteArrays can be compared using overloaded operators such as operator&lt;(), operator&lt;=(), operator==(), operator&gt;=(), and so on. The comparison is based exclusively on the numeric values of the characters and is very fast, but is not what a human would expect. <a href="qstring.html#localeAwareCompare">QString.localeAwareCompare</a>() is a better choice for sorting user-interface strings.</p>
<p>For historical reasons, QByteArray distinguishes between a null byte array and an empty byte array. A <i>null</i> byte array is a byte array that is initialized using QByteArray's default constructor or by passing (const char *)0 to the constructor. An <i>empty</i> byte array is any byte array with size 0. A null byte array is always empty, but an empty byte array isn't necessarily null:</p>
<pre>
    QByteArray().isNull();          // returns true
    QByteArray().isEmpty();         // returns true

    QByteArray("").isNull();        // returns false
    QByteArray("").isEmpty();       // returns true

    QByteArray("abc").isNull();     // returns false
    QByteArray("abc").isEmpty();    // returns false
</pre>
<p>All functions except <a href="qbytearray.html#isNull">isNull</a>() treat null byte arrays the same as empty byte arrays. For example, <a href="qbytearray.html#data">data</a>() returns a pointer to a '\0' character for a null byte array (<i>not</i> a null pointer), and <a href="qbytearray.html#QByteArray">QByteArray</a>() compares equal to QByteArray(""). We recommend that you always use <a href="qbytearray.html#isEmpty">isEmpty</a>() and avoid <a href="qbytearray.html#isNull">isNull</a>().</p>
<a id="note-on-8-bit-character-comparisons" name="note-on-8-bit-character-comparisons" />
<h3>Note on 8-bit Character Comparisons</h3>
<p>In QByteArray, the notion of uppercase and lowercase and of which character is greater than or less than another character is locale dependent. This affects functions that support a case insensitive option or that compare or lowercase or uppercase their arguments. Case insensitive operations and comparisons will be accurate if both strings contain only ASCII characters. (If <tt>$LC_CTYPE</tt> is set, most Unix systems do "the right thing".) Functions that this affects include <a href="qbytearray.html#contains">contains</a>(), <a href="qbytearray.html#indexOf">indexOf</a>(), <a href="qbytearray.html#lastIndexOf">lastIndexOf</a>(), operator&lt;(), operator&lt;=(), operator&gt;(), operator&gt;=(), <a href="qbytearray.html#toLower">toLower</a>() and <a href="qbytearray.html#toUpper">toUpper</a>().</p>
<p>This issue does not apply to QStrings since they represent characters using Unicode.</p>
<p>See also <a href="qstring.html">QString</a> and <a href="qbitarray.html">QBitArray</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QByteArray" />QByteArray.__init__ (<i>self</i>)</h3><p>Constructs an empty byte array.</p>
<p>See also <a href="qbytearray.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QByteArray-2" />QByteArray.__init__ (<i>self</i>, int&#160;<i>size</i>, char&#160;<i>c</i>)</h3><p>Constructs a byte array initialized with the string <i>str</i>.</p>
<p><a href="qbytearray.html">QByteArray</a> makes a deep copy of the string data.</p>
<h3 class="fn"><a name="QByteArray-3" />QByteArray.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Constructs a byte array containing the first <i>size</i> bytes of array <i>data</i>.</p>
<p>If <i>data</i> is 0, a null byte array is constructed.</p>
<p><a href="qbytearray.html">QByteArray</a> makes a deep copy of the string data.</p>
<p>See also <a href="qbytearray.html#fromRawData">fromRawData</a>().</p>
<h3 class="fn"><a name="append" /><a href="qbytearray.html">QByteArray</a> QByteArray.append (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Appends the byte array <i>ba</i> onto the end of this byte array.</p>
<p>Example:</p>
<pre>
    QByteArray x("free");
    QByteArray y("dom");
    x.append(y);
    // x == "freedom"
</pre>
<p>This is the same as insert(<a href="qbytearray.html#size">size</a>(), <i>ba</i>).</p>
<p>This operation is typically very fast (<a href="containers.html#constant-time">constant time</a>), because <a href="qbytearray.html">QByteArray</a> preallocates extra space at the end of the character data so it can grow without reallocating the entire data each time.</p>
<p>See also <a href="qbytearray.html#operator-2b-eq">operator+=</a>(), <a href="qbytearray.html#prepend">prepend</a>(), and <a href="qbytearray.html#insert">insert</a>().</p>
<h3 class="fn"><a name="append-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.append (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Appends the string <i>str</i> to this byte array. The Unicode data is converted into 8-bit characters using <a href="qstring.html#toAscii">QString.toAscii</a>().</p>
<p>If the <a href="qstring.html">QString</a> contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining <tt>QT_NO_CAST_TO_ASCII</tt> when you compile your applications. You then need to call <a href="qstring.html#toAscii">QString.toAscii</a>() (or <a href="qstring.html#toLatin1">QString.toLatin1</a>() or <a href="qstring.html#toUtf8">QString.toUtf8</a>() or <a href="qstring.html#toLocal8Bit">QString.toLocal8Bit</a>()) explicitly if you want to convert the data to <tt>const char *</tt>.</p>
<h3 class="fn"><a name="at" />char QByteArray.at (<i>self</i>, int&#160;<i>i</i>)</h3><p>Returns the character at index position <i>i</i> in the byte array.</p>
<p><i>i</i> must be a valid index position in the byte array (i.e., 0 &lt;= <i>i</i> &lt; <a href="qbytearray.html#size">size</a>()).</p>
<p>See also <a href="qbytearray.html#operator-5b-5d">operator[]</a>().</p>
<h3 class="fn"><a name="capacity" />int QByteArray.capacity (<i>self</i>)</h3><p>Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocation.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qbytearray.html">QByteArray</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many bytes are in the byte array, call <a href="qbytearray.html#size">size</a>().</p>
<p>See also <a href="qbytearray.html#reserve">reserve</a>() and <a href="qbytearray.html#squeeze">squeeze</a>().</p>
<h3 class="fn"><a name="chop" />QByteArray.chop (<i>self</i>, int&#160;<i>n</i>)</h3><p>Removes <i>n</i> bytes from the end of the byte array.</p>
<p>If <i>n</i> is greater than <a href="qbytearray.html#size">size</a>(), the result is an empty byte array.</p>
<p>Example:</p>
<pre>
    QByteArray ba("STARTTLS\r\n");
    ba.chop(2);                 // ba == "STARTTLS"
</pre>
<p>See also <a href="qbytearray.html#truncate">truncate</a>(), <a href="qbytearray.html#resize">resize</a>(), and <a href="qbytearray.html#left">left</a>().</p>
<h3 class="fn"><a name="clear" />QByteArray.clear (<i>self</i>)</h3><p>Clears the contents of the byte array and makes it empty.</p>
<p>See also <a href="qbytearray.html#resize">resize</a>() and <a href="qbytearray.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="contains" />bool QByteArray.contains (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Returns true if the byte array contains an occurrence of the byte array <i>ba</i>; otherwise returns false.</p>
<p>See also <a href="qbytearray.html#indexOf">indexOf</a>() and <a href="qbytearray.html#count">count</a>().</p>
<h3 class="fn"><a name="count" />int QByteArray.count (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Returns the number of (potentially overlapping) occurrences of byte array <i>ba</i> in this byte array.</p>
<p>See also <a href="qbytearray.html#contains">contains</a>() and <a href="qbytearray.html#indexOf">indexOf</a>().</p>
<h3 class="fn"><a name="count-2" />int QByteArray.count (<i>self</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the number of (potentially overlapping) occurrences of string <i>str</i> in the byte array.</p>
<h3 class="fn"><a name="data" />object QByteArray.data (<i>self</i>)</h3><p>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.</p>
<p>Example:</p>
<pre>
    QByteArray ba("Hello world");
    char *data = ba.data();
    while (*data) {
        cout &lt;&lt; "[" &lt;&lt; *data &lt;&lt; "]" &lt;&lt; endl;
        ++data;
    }
</pre>
<p>The pointer remains valid as long as the byte array isn't reallocated.</p>
<p>This function is mostly useful to pass a byte array to a function that accepts a <tt>const char *</tt>.</p>
<p>Note: A <a href="qbytearray.html">QByteArray</a> can store any byte values including '\0's, but most functions that take <tt>char *</tt> arguments assume that the data ends at the first '\0' they encounter.</p>
<p>See also <a href="qbytearray.html#constData">constData</a>() and <a href="qbytearray.html#operator-5b-5d">operator[]</a>().</p>
<h3 class="fn"><a name="endsWith" />bool QByteArray.endsWith (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Returns true if this byte array ends with byte array <i>ba</i>; otherwise returns false.</p>
<p>Example:</p>
<pre>
    QByteArray url("http://www.trolltech.com/index.html");
    if (url.endsWith(".html"))
        ...
</pre>
<p>See also <a href="qbytearray.html#startsWith">startsWith</a>() and <a href="qbytearray.html#right">right</a>().</p>
<h3 class="fn"><a name="fill" /><a href="qbytearray.html">QByteArray</a> QByteArray.fill (<i>self</i>, char&#160;<i>c</i>, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Sets every byte in the byte array to character <i>ch</i>. If <i>size</i> is different from -1 (the default), the byte array is resized to size <i>size</i> beforehand.</p>
<p>Example:</p>
<pre>
    QByteArray ba("Istambul");
    ba.fill("o");
    // ba == "oooooooo"

    ba.fill("X", 2);
    // ba == "XX"
</pre>
<p>See also <a href="qbytearray.html#resize">resize</a>().</p>
<h3 class="fn"><a name="fromBase64" /><a href="qbytearray.html">QByteArray</a> QByteArray.fromBase64 (<a href="qbytearray.html">QByteArray</a>&#160;<i>base64</i>)</h3><p>Returns a decoded copy of the Base64 array <i>base64</i>. For example:</p>
<pre>
    QByteArray text = QByteArray.fromBase64("UXQgaXMgZ3JlYXRcIQo=");
    text.data();            // returns "Qt is great!"
</pre>
<p>See also <a href="qbytearray.html#toBase64">toBase64</a>().</p>
<h3 class="fn"><a name="fromRawData" /><a href="qbytearray.html">QByteArray</a> QByteArray.fromRawData (str)</h3><p>Constructs a <a href="qbytearray.html">QByteArray</a> that uses the first <i>size</i> characters in the array <i>data</i>. The bytes in <i>data</i> are <i>not</i> copied. The caller must be able to guarantee that <i>data</i> will not be deleted or modified as long as the <a href="qbytearray.html">QByteArray</a> (or an unmodified copy of it) exists.</p>
<p>Any attempts to modify the <a href="qbytearray.html">QByteArray</a> or copies of it will cause it to create a deep copy of the data, ensuring that the raw data isn't modified.</p>
<p>Here's an example of how we can read data using a <a href="qdatastream.html">QDataStream</a> on raw data in memory without requiring to copy the data into a <a href="qbytearray.html">QByteArray</a>:</p>
<pre>
     static const char mydata[] = {
        0x00, 0x00, 0x03, 0x84, 0x78, 0x9c, 0x3b, 0x76,
        0xec, 0x18, 0xc3, 0x31, 0x0a, 0xf1, 0xcc, 0x99,
        ...
        0x6d, 0x5b
    };

    QByteArray data = QByteArray.fromRawData(mydata, sizeof(mydata));
    QDataStream in(&amp;data, QIODevice.ReadOnly);
    ...
</pre>
<p><b>Warning:</b> A byte array created with fromRawData() is <i>not</i> null-terminated, unless the raw data contains a 0 character at position <i>size</i>. While that does not matter for <a href="qdatastream.html">QDataStream</a> or functions like <a href="qbytearray.html#indexOf">indexOf</a>(), passing the byte array to a function that accepts a <tt>const char *</tt> and expects it to be '\0'-terminated leads into trouble.</p>
<p>See also <a href="qbytearray.html#data">data</a>() and <a href="qbytearray.html#constData">constData</a>().</p>
<h3 class="fn"><a name="indexOf" />int QByteArray.indexOf (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>, int&#160;<i>from</i>&#160;=&#160;0)</h3><p>Returns the index position of the first occurrence of the byte array <i>ba</i> in this byte array, searching forward from index position <i>from</i>. Returns -1 if <i>ba</i> could not be found.</p>
<p>Example:</p>
<pre>
    QByteArray x("sticky question");
    QByteArray y("sti");
    x.indexOf(y);               // returns 0
    x.indexOf(y, 1);            // returns 10
    x.indexOf(y, 10);           // returns 10
    x.indexOf(y, 11);           // returns -1
</pre>
<p>See also <a href="qbytearray.html#lastIndexOf">lastIndexOf</a>(), <a href="qbytearray.html#contains">contains</a>(), and <a href="qbytearray.html#count">count</a>().</p>
<h3 class="fn"><a name="indexOf-2" />int QByteArray.indexOf (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;0)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the index position of the first occurrence of the string <i>str</i> in the byte array, searching forward from index position <i>from</i>. Returns -1 if <i>str</i> could not be found.</p>
<p>The Unicode data is converted into 8-bit characters using <a href="qstring.html#toAscii">QString.toAscii</a>().</p>
<p>If the <a href="qstring.html">QString</a> contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining <tt>QT_NO_CAST_TO_ASCII</tt> when you compile your applications. You then need to call <a href="qstring.html#toAscii">QString.toAscii</a>() (or <a href="qstring.html#toLatin1">QString.toLatin1</a>() or <a href="qstring.html#toUtf8">QString.toUtf8</a>() or <a href="qstring.html#toLocal8Bit">QString.toLocal8Bit</a>()) explicitly if you want to convert the data to <tt>const char *</tt>.</p>
<h3 class="fn"><a name="insert" /><a href="qbytearray.html">QByteArray</a> QByteArray.insert (<i>self</i>, int&#160;<i>i</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Inserts the byte array <i>ba</i> at index position <i>i</i> and returns a reference to this byte array.</p>
<p>Example:</p>
<pre>
    QByteArray ba("Meal");
    ba.insert(1, QByteArray("ontr"));
    // ba == "Montreal"
</pre>
<p>See also <a href="qbytearray.html#append">append</a>(), <a href="qbytearray.html#prepend">prepend</a>(), <a href="qbytearray.html#replace">replace</a>(), and <a href="qbytearray.html#remove">remove</a>().</p>
<h3 class="fn"><a name="insert-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.insert (<i>self</i>, int&#160;<i>i</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Inserts the string <i>str</i> at index position <i>i</i> in the byte array. The Unicode data is converted into 8-bit characters using <a href="qstring.html#toAscii">QString.toAscii</a>().</p>
<p>If <i>i</i> is greater than <a href="qbytearray.html#size">size</a>(), the array is first extended using <a href="qbytearray.html#resize">resize</a>().</p>
<p>If the <a href="qstring.html">QString</a> contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining <tt>QT_NO_CAST_TO_ASCII</tt> when you compile your applications. You then need to call <a href="qstring.html#toAscii">QString.toAscii</a>() (or <a href="qstring.html#toLatin1">QString.toLatin1</a>() or <a href="qstring.html#toUtf8">QString.toUtf8</a>() or <a href="qstring.html#toLocal8Bit">QString.toLocal8Bit</a>()) explicitly if you want to convert the data to <tt>const char *</tt>.</p>
<h3 class="fn"><a name="isEmpty" />bool QByteArray.isEmpty (<i>self</i>)</h3><p>Returns true if the byte array has size 0; otherwise returns false.</p>
<p>Example:</p>
<pre>
    QByteArray().isEmpty();         // returns true
    QByteArray("").isEmpty();       // returns true
    QByteArray("abc").isEmpty();    // returns false
</pre>
<p>See also <a href="qbytearray.html#size">size</a>().</p>
<h3 class="fn"><a name="isNull" />bool QByteArray.isNull (<i>self</i>)</h3><p>Returns true if this byte array is null; otherwise returns false.</p>
<p>Example:</p>
<pre>
    QByteArray().isNull();          // returns true
    QByteArray("").isNull();        // returns false
    QByteArray("abc").isNull();     // returns false
</pre>
<p>Qt makes a distinction between null byte arrays and empty byte arrays for historical reasons. For most applications, what matters is whether or not a byte array contains any data, and this can be determined using <a href="qbytearray.html#isEmpty">isEmpty</a>().</p>
<p>See also <a href="qbytearray.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="lastIndexOf" />int QByteArray.lastIndexOf (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>, int&#160;<i>from</i>&#160;=&#160;-1)</h3><p>Returns the index position of the last occurrence of the byte array <i>ba</i> in this byte array, searching backward from index position <i>from</i>. If <i>from</i> is -1 (the default), the search starts at the last byte. Returns -1 if <i>ba</i> could not be found.</p>
<p>Example:</p>
<pre>
    QByteArray x("crazy azimuths");
    QByteArray y("azy");
    x.lastIndexOf(y);           // returns 6
    x.lastIndexOf(y, 6);        // returns 6
    x.lastIndexOf(y, 5);        // returns 2
    x.lastIndexOf(y, 1);        // returns -1
</pre>
<p>See also <a href="qbytearray.html#indexOf">indexOf</a>(), <a href="qbytearray.html#contains">contains</a>(), and <a href="qbytearray.html#count">count</a>().</p>
<h3 class="fn"><a name="lastIndexOf-2" />int QByteArray.lastIndexOf (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;-1)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the index position of the last occurrence of the string <i>str</i> in the byte array, searching backward from index position <i>from</i>. If <i>from</i> is -1 (the default), the search starts at the last (<a href="qbytearray.html#size">size</a>() - 1) byte. Returns -1 if <i>str</i> could not be found.</p>
<p>The Unicode data is converted into 8-bit characters using <a href="qstring.html#toAscii">QString.toAscii</a>().</p>
<p>If the <a href="qstring.html">QString</a> contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining <tt>QT_NO_CAST_TO_ASCII</tt> when you compile your applications. You then need to call <a href="qstring.html#toAscii">QString.toAscii</a>() (or <a href="qstring.html#toLatin1">QString.toLatin1</a>() or <a href="qstring.html#toUtf8">QString.toUtf8</a>() or <a href="qstring.html#toLocal8Bit">QString.toLocal8Bit</a>()) explicitly if you want to convert the data to <tt>const char *</tt>.</p>
<h3 class="fn"><a name="left" /><a href="qbytearray.html">QByteArray</a> QByteArray.left (<i>self</i>, int&#160;<i>len</i>)</h3><p>Returns a byte array that contains the leftmost <i>len</i> bytes of this byte array.</p>
<p>The entire byte array is returned if <i>len</i> is greater than <a href="qbytearray.html#size">size</a>().</p>
<p>Example:</p>
<pre>
    QByteArray x("Pineapple");
    QByteArray y = x.left(4);
    // y == "Pine"
</pre>
<p>See also <a href="qbytearray.html#right">right</a>(), <a href="qbytearray.html#mid">mid</a>(), <a href="qbytearray.html#startsWith">startsWith</a>(), and <a href="qbytearray.html#truncate">truncate</a>().</p>
<h3 class="fn"><a name="leftJustified" /><a href="qbytearray.html">QByteArray</a> QByteArray.leftJustified (<i>self</i>, int&#160;<i>width</i>, char&#160;<i>fill</i>&#160;=&#160;' ', bool&#160;<i>truncate</i>&#160;=&#160;False)</h3><p>Returns a byte array of size <i>width</i> that contains this byte array padded by the <i>fill</i> character.</p>
<p>If <i>truncate</i> is false and the <a href="qbytearray.html#size">size</a>() of the byte array is more than <i>width</i>, then the returned byte array is a copy of this byte array.</p>
<p>If <i>truncate</i> is true and the <a href="qbytearray.html#size">size</a>() of the byte array is more than <i>width</i>, then any bytes in a copy of the byte array after position <i>width</i> are removed, and the copy is returned.</p>
<p>Example:</p>
<pre>
    QByteArray x("apple");
    QByteArray y = x.leftJustified(8, '.');   // y == "apple..."
</pre>
<p>See also <a href="qbytearray.html#rightJustified">rightJustified</a>().</p>
<h3 class="fn"><a name="length" />int QByteArray.length (<i>self</i>)</h3><p>Same as <a href="qbytearray.html#size">size</a>().</p>
<h3 class="fn"><a name="mid" /><a href="qbytearray.html">QByteArray</a> QByteArray.mid (<i>self</i>, int&#160;<i>index</i>, int&#160;<i>len</i>&#160;=&#160;-1)</h3><p>Returns a byte array containing <i>len</i> bytes from this byte array, starting at position <i>pos</i>.</p>
<p>If <i>len</i> is -1 (the default), or <i>pos</i> + <i>len</i> &gt;= <a href="qbytearray.html#size">size</a>(), returns a byte array containing all bytes starting at position <i>pos</i> until the end of the byte array.</p>
<p>Example:</p>
<pre>
    QByteArray x("Five pineapples");
    QByteArray y = x.mid(5, 4);     // y == "pine"
    QByteArray z = x.mid(5);        // z == "pineapples"
</pre>
<p>See also <a href="qbytearray.html#left">left</a>() and <a href="qbytearray.html#right">right</a>().</p>
<h3 class="fn"><a name="number" /><a href="qbytearray.html">QByteArray</a> QByteArray.number (int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns a byte array containing the string equivalent of the number <i>n</i> to base <i>base</i> (10 by default). The <i>base</i> can be any value between 2 and 36.</p>
<p>Example:</p>
<pre>
    int n = 63;
    QByteArray.number(n);              // returns "63"
    QByteArray.number(n, 16);          // returns "3f"
    QByteArray.number(n, 16).upper();  // returns "3F"
</pre>
<p>See also <a href="qbytearray.html#setNum">setNum</a>() and <a href="qbytearray.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="number-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.number (float, char&#160;<i>f</i>&#160;=&#160;'g', int&#160;<i>prec</i>&#160;=&#160;6)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>See also <a href="qbytearray.html#toUInt">toUInt</a>().</p>
<h3 class="fn"><a name="number-3" /><a href="qbytearray.html">QByteArray</a> QByteArray.number (long, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>See also <a href="qbytearray.html#toLongLong">toLongLong</a>().</p>
<h3 class="fn"><a name="number-4" /><a href="qbytearray.html">QByteArray</a> QByteArray.number (unsigned long, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>See also <a href="qbytearray.html#toULongLong">toULongLong</a>().</p>
<h3 class="fn"><a name="prepend" /><a href="qbytearray.html">QByteArray</a> QByteArray.prepend (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Prepends the byte array <i>ba</i> to this byte array and returns a reference to this byte array.</p>
<p>Example:</p>
<pre>
    QByteArray x("ship");
    QByteArray y("air");
    x.prepend(y);
    // x == "airship"
</pre>
<p>This is the same as insert(0, <i>ba</i>).</p>
<p>See also <a href="qbytearray.html#append">append</a>() and <a href="qbytearray.html#insert">insert</a>().</p>
<h3 class="fn"><a name="push_back" />QByteArray.push_back (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>This function is provided for STL compatibility. It is equivalent to append(<i>other</i>).</p>
<h3 class="fn"><a name="push_front" />QByteArray.push_front (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>This function is provided for STL compatibility. It is equivalent to prepend(<i>other</i>).</p>
<h3 class="fn"><a name="remove" /><a href="qbytearray.html">QByteArray</a> QByteArray.remove (<i>self</i>, int&#160;<i>index</i>, int&#160;<i>len</i>)</h3><p>Removes <i>len</i> bytes from the array, starting at index position <i>pos</i>, and returns a reference to the array.</p>
<p>If <i>pos</i> is out of range, nothing happens. If <i>pos</i> is valid, but <i>pos</i> + <i>len</i> is larger than the size of the array, the array is truncated at position <i>pos</i>.</p>
<p>Example:</p>
<pre>
    QByteArray ba("Montreal");
    ba.remove(1, 4);
    // ba == "Meal"
</pre>
<p>See also <a href="qbytearray.html#insert">insert</a>() and <a href="qbytearray.html#replace">replace</a>().</p>
<h3 class="fn"><a name="replace" /><a href="qbytearray.html">QByteArray</a> QByteArray.replace (<i>self</i>, int&#160;<i>index</i>, int&#160;<i>len</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><p>Replaces <i>len</i> bytes from index position <i>pos</i> with the byte array <i>after</i>, and returns a reference to this byte array.</p>
<p>Example:</p>
<pre>
    QByteArray x("Say yes!");
    QByteArray y("no");
    x.replace(4, 3, y);
    // x == "Say no!"
</pre>
<p>See also <a href="qbytearray.html#insert">insert</a>() and <a href="qbytearray.html#remove">remove</a>().</p>
<h3 class="fn"><a name="replace-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.replace (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>before</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>after</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="replace-3" /><a href="qbytearray.html">QByteArray</a> QByteArray.replace (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>before</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>after</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Replaces every occurrence of the byte array <i>before</i> with the byte array <i>after</i>.</p>
<p>Example:</p>
<pre>
    QByteArray ba("colour behaviour flavour neighbour");
    ba.replace(QByteArray("ou"), QByteArray("o"));
    // ba == "color behavior flavor neighbor"
</pre>
<h3 class="fn"><a name="reserve" />QByteArray.reserve (<i>self</i>, int&#160;<i>size</i>)</h3><p>Attempts to allocate memory for at least <i>size</i> bytes. If you know in advance how large the byte array will be, you can call this function, and if you call <a href="qbytearray.html#resize">resize</a>() often you are likely to get better performance. If <i>size</i> is an underestimate, the worst that will happen is that the <a href="qbytearray.html">QByteArray</a> will be a bit slower.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qbytearray.html">QByteArray</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the byte array, call <a href="qbytearray.html#resize">resize</a>().</p>
<p>See also <a href="qbytearray.html#squeeze">squeeze</a>() and <a href="qbytearray.html#capacity">capacity</a>().</p>
<h3 class="fn"><a name="resize" />QByteArray.resize (<i>self</i>, int&#160;<i>size</i>)</h3><p>Sets the size of the byte array to <i>size</i> bytes.</p>
<p>If <i>size</i> is greater than the current size, the byte array is extended to make it <i>size</i> bytes with the extra bytes added to the end. The new bytes are uninitialized.</p>
<p>If <i>size</i> is less than the current size, bytes are removed from the end.</p>
<p>See also <a href="qbytearray.html#size">size</a>().</p>
<h3 class="fn"><a name="right" /><a href="qbytearray.html">QByteArray</a> QByteArray.right (<i>self</i>, int&#160;<i>len</i>)</h3><p>Returns a byte array that contains the rightmost <i>len</i> bytes of this byte array.</p>
<p>The entire byte array is returned if <i>len</i> is greater than <a href="qbytearray.html#size">size</a>().</p>
<p>Example:</p>
<pre>
    QByteArray x("Pineapple");
    QByteArray y = x.right(5);
    // y == "apple"
</pre>
<p>See also <a href="qbytearray.html#endsWith">endsWith</a>(), <a href="qbytearray.html#left">left</a>(), and <a href="qbytearray.html#mid">mid</a>().</p>
<h3 class="fn"><a name="rightJustified" /><a href="qbytearray.html">QByteArray</a> QByteArray.rightJustified (<i>self</i>, int&#160;<i>width</i>, char&#160;<i>fill</i>&#160;=&#160;' ', bool&#160;<i>truncate</i>&#160;=&#160;False)</h3><p>Returns a byte array of size <i>width</i> that contains the <i>fill</i> character followed by this byte array.</p>
<p>If <i>truncate</i> is false and the size of the byte array is more than <i>width</i>, then the returned byte array is a copy of this byte array.</p>
<p>If <i>truncate</i> is true and the size of the byte array is more than <i>width</i>, then the resulting byte array is truncated at position <i>width</i>.</p>
<p>Example:</p>
<pre>
    QByteArray x("apple");
    QByteArray y = x.rightJustified(8, '.');    // y == "...apple"
</pre>
<p>See also <a href="qbytearray.html#leftJustified">leftJustified</a>().</p>
<h3 class="fn"><a name="setNum" /><a href="qbytearray.html">QByteArray</a> QByteArray.setNum (<i>self</i>, int&#160;<i>n</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Sets the byte array to the printed value of <i>n</i> in base <i>base</i> (10 by default) and returns a reference to the byte array. The <i>base</i> can be any value between 2 and 36.</p>
<p>Example:</p>
<pre>
    QByteArray ba;
    int n = 63;
    ba.setNum(n);           // ba == "63"
    ba.setNum(n, 16);       // ba == "3f"
</pre>
<p>See also <a href="qbytearray.html#number">number</a>() and <a href="qbytearray.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="setNum-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.setNum (<i>self</i>, float, char&#160;<i>f</i>&#160;=&#160;'g', int&#160;<i>prec</i>&#160;=&#160;6)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>See also <a href="qbytearray.html#toUInt">toUInt</a>().</p>
<h3 class="fn"><a name="setNum-3" /><a href="qbytearray.html">QByteArray</a> QByteArray.setNum (<i>self</i>, long, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>See also <a href="qbytearray.html#toShort">toShort</a>().</p>
<h3 class="fn"><a name="setNum-4" /><a href="qbytearray.html">QByteArray</a> QByteArray.setNum (<i>self</i>, unsigned long, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>See also <a href="qbytearray.html#toUShort">toUShort</a>().</p>
<h3 class="fn"><a name="simplified" /><a href="qbytearray.html">QByteArray</a> QByteArray.simplified (<i>self</i>)</h3><p>Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.</p>
<p>Whitespace means any character for which the standard C++ isspace() function returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.</p>
<p>Example:</p>
<pre>
    QByteArray ba("  lots\t of\nwhitespace\r\n ");
    ba = ba.simplified();
    // ba == "lots of whitespace";
</pre>
<p>See also <a href="qbytearray.html#trimmed">trimmed</a>().</p>
<h3 class="fn"><a name="size" />int QByteArray.size (<i>self</i>)</h3><p>Returns the number of bytes in this byte array.</p>
<p>The last byte in the byte array is at position size() - 1. In addition, <a href="qbytearray.html">QByteArray</a> ensures that the byte at position size() is always '\0', so that you can use the return value of <a href="qbytearray.html#data">data</a>() and <a href="qbytearray.html#constData">constData</a>() as arguments to functions that expect '\0'-terminated strings.</p>
<p>Example:</p>
<pre>
    QByteArray ba("Hello");
    int n = ba.size();          // n == 5
    ba.data()[0];               // returns 'H'
    ba.data()[4];               // returns 'o'
    ba.data()[5];               // returns '\0'
</pre>
<p>See also <a href="qbytearray.html#isEmpty">isEmpty</a>() and <a href="qbytearray.html#resize">resize</a>().</p>
<h3 class="fn"><a name="split" />QByteArray-list QByteArray.split (<i>self</i>, char&#160;<i>sep</i>)</h3><p>Splits the byte array into subarrays wherever <i>sep</i> occurs, and returns the list of those arrays. If <i>sep</i> does not match anywhere in the byte array, split() returns a single-element list containing this byte array.</p>
<h3 class="fn"><a name="squeeze" />QByteArray.squeeze (<i>self</i>)</h3><p>Releases any memory not required to store the array's data.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qbytearray.html">QByteArray</a>'s memory usage. In general, you will rarely ever need to call this function.</p>
<p>See also <a href="qbytearray.html#reserve">reserve</a>() and <a href="qbytearray.html#capacity">capacity</a>().</p>
<h3 class="fn"><a name="startsWith" />bool QByteArray.startsWith (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Returns true if this byte array starts with byte array <i>ba</i>; otherwise returns false.</p>
<p>Example:</p>
<pre>
    QByteArray url("ftp://ftp.trolltech.com/");
    if (url.startsWith("ftp:"))
        ...
</pre>
<p>See also <a href="qbytearray.html#endsWith">endsWith</a>() and <a href="qbytearray.html#left">left</a>().</p>
<h3 class="fn"><a name="toBase64" /><a href="qbytearray.html">QByteArray</a> QByteArray.toBase64 (<i>self</i>)</h3><p>Returns a copy of the byte array, encoded as Base64.</p>
<pre>
    QByteArray text("Qt is great!");
    text.toBase64();        // returns "UXQgaXMgZ3JlYXRcIQo="
</pre>
<p>See also <a href="qbytearray.html#fromBase64">fromBase64</a>().</p>
<h3 class="fn"><a name="toDouble" />(float, bool&#160;<i>ok</i>) QByteArray.toDouble (<i>self</i>)</h3><p>Returns the byte array converted to a <tt>double</tt> value.</p>
<p>Returns 0.0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<pre>
    QByteArray string("1234.56");
    double a = string.toDouble();   // a == 1234.56
</pre>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toFloat" />(float, bool&#160;<i>ok</i>) QByteArray.toFloat (<i>self</i>)</h3><p>Returns the byte array converted to a <tt>float</tt> value.</p>
<p>Returns 0.0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toInt" />(int, bool&#160;<i>ok</i>) QByteArray.toInt (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to an <tt>int</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<pre>
    QByteArray str("FF");
    bool ok;
    int hex = str.toInt(&amp;ok, 16);     // hex == 255, ok == true
    int dec = str.toInt(&amp;ok, 10);     // dec == 0, ok == false
</pre>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toLong" />(long, bool&#160;<i>ok</i>) QByteArray.toLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to a <tt>long</tt> int using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<pre>
    QByteArray str("FF");
    bool ok;
    long hex = str.toLong(&amp;ok, 16);   // hex == 255, ok == true
    long dec = str.toLong(&amp;ok, 10);   // dec == 0, ok == false
</pre>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toLongLong" />(long, bool&#160;<i>ok</i>) QByteArray.toLongLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to a <tt>long long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toLower" /><a href="qbytearray.html">QByteArray</a> QByteArray.toLower (<i>self</i>)</h3><p>Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.</p>
<p>Example:</p>
<pre>
    QByteArray x("TROlltECH");
    QByteArray y = x.toLower();
    // y == "trolltech"
</pre>
<p>See also <a href="qbytearray.html#toUpper">toUpper</a>() and <a href="qbytearray.html#note-on-8-bit-character-comparisons">Note on 8-bit character comparisons</a>.</p>
<h3 class="fn"><a name="toShort" />(int, bool&#160;<i>ok</i>) QByteArray.toShort (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to a <tt>short</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toUInt" />(unsigned long, bool&#160;<i>ok</i>) QByteArray.toUInt (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to an <tt>unsigned int</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toULong" />(unsigned long, bool&#160;<i>ok</i>) QByteArray.toULong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to an <tt>unsigned long int</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toULongLong" />(unsigned long, bool&#160;<i>ok</i>) QByteArray.toULongLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to an <tt>unsigned long long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="toUpper" /><a href="qbytearray.html">QByteArray</a> QByteArray.toUpper (<i>self</i>)</h3><p>Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.</p>
<p>Example:</p>
<pre>
    QByteArray x("TROlltECH");
    QByteArray y = x.toUpper();
    // y == "TROLLTECH"
</pre>
<p>See also <a href="qbytearray.html#toLower">toLower</a>() and <a href="qbytearray.html#note-on-8-bit-character-comparisons">Note on 8-bit character comparisons</a>.</p>
<h3 class="fn"><a name="toUShort" />(unsigned long, bool&#160;<i>ok</i>) QByteArray.toUShort (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the byte array converted to an <tt>unsigned short</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0.</p>
<p>If <i>base</i> is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.</p>
<p>Returns 0 if the conversion fails.</p>
<p>If <i>ok</i> is not 0: if a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>See also <a href="qbytearray.html#number">number</a>().</p>
<h3 class="fn"><a name="trimmed" /><a href="qbytearray.html">QByteArray</a> QByteArray.trimmed (<i>self</i>)</h3><p>Returns a byte array that has whitespace removed from the start and the end.</p>
<p>Whitespace means any character for which the standard C++ isspace() function returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.</p>
<p>Example:</p>
<pre>
    QByteArray ba("  lots\t of\nwhitespace\r\n ");
    ba = ba.trimmed();
    // ba == "lots\t of\nwhitespace";
</pre>
<p>Unlike <a href="qbytearray.html#simplified">simplified</a>(), trimmed() leaves internal whitespace alone.</p>
<p>See also <a href="qbytearray.html#simplified">simplified</a>().</p>
<h3 class="fn"><a name="truncate" />QByteArray.truncate (<i>self</i>, int&#160;<i>pos</i>)</h3><p>Truncates the byte array at index position <i>pos</i>.</p>
<p>If <i>pos</i> is beyond the end of the array, nothing happens.</p>
<p>Example:</p>
<pre>
    QByteArray ba("Stockholm");
    ba.truncate(5);             // ba == "Stock"
</pre>
<p>See also <a href="qbytearray.html#chop">chop</a>(), <a href="qbytearray.html#resize">resize</a>(), and <a href="qbytearray.html#left">left</a>().</p>
<h3 class="fn"><a name="__add__" /><a href="qstring.html">QString</a> QByteArray.__add__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__add__-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.__add__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__contains__" />int QByteArray.__contains__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><h3 class="fn"><a name="__eq__" />bool QByteArray.__eq__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__eq__-2" />bool QByteArray.__eq__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__ge__" />bool QByteArray.__ge__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__ge__-2" />bool QByteArray.__ge__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__getitem__" />char QByteArray.__getitem__ (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="__getitem__-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.__getitem__ (<i>self</i>, slice&#160;<i>slice</i>)</h3><h3 class="fn"><a name="__gt__" />bool QByteArray.__gt__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__gt__-2" />bool QByteArray.__gt__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__hash__" />long QByteArray.__hash__ (<i>self</i>)</h3><h3 class="fn"><a name="__iadd__" /><a href="qbytearray.html">QByteArray</a> QByteArray.__iadd__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><h3 class="fn"><a name="__iadd__-2" /><a href="qbytearray.html">QByteArray</a> QByteArray.__iadd__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__imul__" /><a href="qbytearray.html">QByteArray</a> QByteArray.__imul__ (<i>self</i>, int&#160;<i>m</i>)</h3><h3 class="fn"><a name="__le__" />bool QByteArray.__le__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__le__-2" />bool QByteArray.__le__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__len__" />int QByteArray.__len__ (<i>self</i>)</h3><h3 class="fn"><a name="__lt__" />bool QByteArray.__lt__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__lt__-2" />bool QByteArray.__lt__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__mul__" /><a href="qbytearray.html">QByteArray</a> QByteArray.__mul__ (<i>self</i>, int&#160;<i>m</i>)</h3><h3 class="fn"><a name="__ne__" />bool QByteArray.__ne__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a2</i>)</h3><h3 class="fn"><a name="__ne__-2" />bool QByteArray.__ne__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__str__" />object QByteArray.__str__ (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 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.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>