File: qstring.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 (921 lines) | stat: -rw-r--r-- 123,615 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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
<?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>QString 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">QString Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QString class provides a Unicode character string. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qstring.html#NormalizationForm-enum">NormalizationForm</a></b> { NormalizationForm_D, NormalizationForm_C, NormalizationForm_KD, NormalizationForm_KC }</li><li><div class="fn" />enum <b><a href="qstring.html#SectionFlag-enum">SectionFlag</a></b> { SectionDefault, SectionSkipEmpty, SectionIncludeLeadingSep, SectionIncludeTrailingSep, SectionCaseInsensitiveSeps }</li><li><div class="fn" />class <b><a href="qstring-sectionflags.html">SectionFlags</a></b></li><li><div class="fn" />enum <b><a href="qstring.html#SplitBehavior-enum">SplitBehavior</a></b> { KeepEmptyParts, SkipEmptyParts }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstring.html#QString">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString">__init__</a></b> (<i>self</i>, QKeySequence)</li><li><div class="fn" /><b><a href="qstring.html#QString-2">__init__</a></b> (<i>self</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString-3">__init__</a></b> (<i>self</i>, int&#160;<i>size</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString-4">__init__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString-5">__init__</a></b> (<i>self</i>, QLatin1String&#160;<i>latin1</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString-6">__init__</a></b> (<i>self</i>, QByteArray&#160;<i>a</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString-7">__init__</a></b> (<i>self</i>, QUuid)</li><li><div class="fn" />QString <b><a href="qstring.html#append">append</a></b> (<i>self</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#append-2">append</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#append-3">append</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#append-4">append</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#arg">arg</a></b> (<i>self</i>, int&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-2">arg</a></b> (<i>self</i>, float&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, char&#160;<i>fmt</i>&#160;=&#160;'g', int&#160;<i>prec</i>&#160;=&#160;-1, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-3">arg</a></b> (<i>self</i>, long&#160;<i>a</i>, int&#160;<i>fieldwidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-4">arg</a></b> (<i>self</i>, unsigned long&#160;<i>a</i>, int&#160;<i>fieldwidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-5">arg</a></b> (<i>self</i>, QChar&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-6">arg</a></b> (<i>self</i>, QString&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-7">arg</a></b> (<i>self</i>, QString&#160;<i>a1</i>, QString&#160;<i>a2</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-8">arg</a></b> (<i>self</i>, QString&#160;<i>a1</i>, QString&#160;<i>a2</i>, QString&#160;<i>a3</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-9">arg</a></b> (<i>self</i>, QString&#160;<i>a1</i>, QString&#160;<i>a2</i>, QString&#160;<i>a3</i>, QString&#160;<i>a4</i>)</li><li><div class="fn" />QChar <b><a href="qstring.html#at">at</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />int <b><a href="qstring.html#capacity">capacity</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstring.html#chop">chop</a></b> (<i>self</i>, int&#160;<i>n</i>)</li><li><div class="fn" /><b><a href="qstring.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#compare">compare</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#contains">contains</a></b> (<i>self</i>, QString&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#contains-2">contains</a></b> (<i>self</i>, QChar&#160;<i>c</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#contains-3">contains</a></b> (<i>self</i>, QRegExp&#160;<i>rx</i>)</li><li><div class="fn" />int <b><a href="qstring.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#count-2">count</a></b> (<i>self</i>, QChar&#160;<i>c</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#count-3">count</a></b> (<i>self</i>, QString&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#count-4">count</a></b> (<i>self</i>, QRegExp)</li><li><div class="fn" />bool <b><a href="qstring.html#endsWith">endsWith</a></b> (<i>self</i>, QString&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#endsWith-2">endsWith</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#endsWith-3">endsWith</a></b> (<i>self</i>, QChar&#160;<i>c</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#fill">fill</a></b> (<i>self</i>, QChar&#160;<i>c</i>, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qstring.html#indexOf">indexOf</a></b> (<i>self</i>, QChar&#160;<i>c</i>, int&#160;<i>from</i>&#160;=&#160;0, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#indexOf-2">indexOf</a></b> (<i>self</i>, QString&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;0, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#indexOf-3">indexOf</a></b> (<i>self</i>, QRegExp, int&#160;<i>from</i>&#160;=&#160;0)</li><li><div class="fn" />QString <b><a href="qstring.html#insert">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#insert-2">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QChar&#160;<i>uc</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#insert-3">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#insert-4">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isRightToLeft">isRightToLeft</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isSimpleText">isSimpleText</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#lastIndexOf">lastIndexOf</a></b> (<i>self</i>, QChar&#160;<i>c</i>, int&#160;<i>from</i>&#160;=&#160;-1, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#lastIndexOf-2">lastIndexOf</a></b> (<i>self</i>, QString&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;-1, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#lastIndexOf-3">lastIndexOf</a></b> (<i>self</i>, QRegExp, int&#160;<i>from</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#left">left</a></b> (<i>self</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#leftJustified">leftJustified</a></b> (<i>self</i>, int&#160;<i>width</i>, QChar&#160;<i>fill</i>&#160;=&#160;QLatin1Char(32), bool&#160;<i>trunc</i>&#160;=&#160;False)</li><li><div class="fn" />int <b><a href="qstring.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#localeAwareCompare">localeAwareCompare</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#mid">mid</a></b> (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#normalized">normalized</a></b> (<i>self</i>, NormalizationForm&#160;<i>mode</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#normalized-2">normalized</a></b> (<i>self</i>, NormalizationForm&#160;<i>mode</i>, QChar.UnicodeVersion&#160;<i>version</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend">prepend</a></b> (<i>self</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend-2">prepend</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend-3">prepend</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend-4">prepend</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qstring.html#push_back">push_back</a></b> (<i>self</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" /><b><a href="qstring.html#push_back-2">push_back</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qstring.html#push_front">push_front</a></b> (<i>self</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" /><b><a href="qstring.html#push_front-2">push_front</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#remove">remove</a></b> (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#remove-2">remove</a></b> (<i>self</i>, QChar&#160;<i>c</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#remove-3">remove</a></b> (<i>self</i>, QString&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#remove-4">remove</a></b> (<i>self</i>, QRegExp&#160;<i>rx</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#replace">replace</a></b> (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>, QChar&#160;<i>after</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-2">replace</a></b> (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>, QChar&#160;<i>s</i>, int&#160;<i>slen</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-3">replace</a></b> (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>, QString&#160;<i>after</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-4">replace</a></b> (<i>self</i>, QChar&#160;<i>before</i>, QChar&#160;<i>after</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-5">replace</a></b> (<i>self</i>, QChar&#160;<i>c</i>, QString&#160;<i>after</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-6">replace</a></b> (<i>self</i>, QString&#160;<i>before</i>, QString&#160;<i>after</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-7">replace</a></b> (<i>self</i>, QRegExp&#160;<i>rx</i>, QString&#160;<i>after</i>)</li><li><div class="fn" /><b><a href="qstring.html#reserve">reserve</a></b> (<i>self</i>, int&#160;<i>asize</i>)</li><li><div class="fn" /><b><a href="qstring.html#resize">resize</a></b> (<i>self</i>, int&#160;<i>size</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#right">right</a></b> (<i>self</i>, int&#160;<i>len</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#rightJustified">rightJustified</a></b> (<i>self</i>, int&#160;<i>width</i>, QChar&#160;<i>fill</i>&#160;=&#160;QLatin1Char(32), bool&#160;<i>trunc</i>&#160;=&#160;False)</li><li><div class="fn" />QString <b><a href="qstring.html#section">section</a></b> (<i>self</i>, QString&#160;<i>in_sep</i>, int&#160;<i>start</i>, int&#160;<i>end</i>&#160;=&#160;-1, SectionFlags&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</li><li><div class="fn" />QString <b><a href="qstring.html#section-2">section</a></b> (<i>self</i>, QRegExp&#160;<i>reg</i>, int&#160;<i>start</i>, int&#160;<i>end</i>&#160;=&#160;-1, SectionFlags&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</li><li><div class="fn" />QString <b><a href="qstring.html#section-3">section</a></b> (<i>self</i>, QChar&#160;<i>asep</i>, int&#160;<i>astart</i>, int&#160;<i>aend</i>&#160;=&#160;-1, SectionFlags&#160;<i>aflags</i>&#160;=&#160;QString.SectionDefault)</li><li><div class="fn" />QString <b><a href="qstring.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" />QString <b><a href="qstring.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" />QString <b><a href="qstring.html#setNum-3">setNum</a></b> (<i>self</i>, long, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#setNum-4">setNum</a></b> (<i>self</i>, unsigned long, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#simplified">simplified</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qstring.html#split">split</a></b> (<i>self</i>, QString&#160;<i>sep</i>, SplitBehavior&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QStringList <b><a href="qstring.html#split-2">split</a></b> (<i>self</i>, QChar&#160;<i>sep</i>, SplitBehavior&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QStringList <b><a href="qstring.html#split-3">split</a></b> (<i>self</i>, QRegExp&#160;<i>sep</i>, SplitBehavior&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts)</li><li><div class="fn" /><b><a href="qstring.html#squeeze">squeeze</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#startsWith">startsWith</a></b> (<i>self</i>, QString&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#startsWith-2">startsWith</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#startsWith-3">startsWith</a></b> (<i>self</i>, QChar&#160;<i>c</i>, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toAscii">toAscii</a></b> (<i>self</i>)</li><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qstring.html#toDouble">toDouble</a></b> (<i>self</i>)</li><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qstring.html#toFloat">toFloat</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toInt">toInt</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toLatin1">toLatin1</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toLocal8Bit">toLocal8Bit</a></b> (<i>self</i>)</li><li><div class="fn" />(long, bool&#160;<i>ok</i>) <b><a href="qstring.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="qstring.html#toLongLong">toLongLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#toLower">toLower</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.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="qstring.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="qstring.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="qstring.html#toULongLong">toULongLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#toUpper">toUpper</a></b> (<i>self</i>)</li><li><div class="fn" />(unsigned long, bool&#160;<i>ok</i>) <b><a href="qstring.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="qstring.html#toUtf8">toUtf8</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#trimmed">trimmed</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstring.html#truncate">truncate</a></b> (<i>self</i>, int&#160;<i>pos</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />int <b><a href="qstring.html#compare-2">compare</a></b> (QString&#160;<i>s1</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#fromAscii">fromAscii</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#fromLatin1">fromLatin1</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#fromUtf8">fromUtf8</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qstring.html#localeAwareCompare-2">localeAwareCompare</a></b> (QString&#160;<i>s1</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#number">number</a></b> (int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.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" />QString <b><a href="qstring.html#number-3">number</a></b> (long, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.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="qstring.html#__add__">__add__</a></b> (<i>self</i>, QByteArray&#160;<i>ba</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__add__-2">__add__</a></b> (<i>self</i>, QChar&#160;<i>s2</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__add__-3">__add__</a></b> (<i>self</i>, QString&#160;<i>s2</i>)</li><li><div class="fn" />int <b><a href="qstring.html#__contains__">__contains__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__">__eq__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__-2">__eq__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__-3">__eq__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ge__">__ge__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ge__-2">__ge__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ge__-3">__ge__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__getitem__">__getitem__</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__getitem__-2">__getitem__</a></b> (<i>self</i>, slice&#160;<i>slice</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__gt__">__gt__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__gt__-2">__gt__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__gt__-3">__gt__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />long <b><a href="qstring.html#__hash__">__hash__</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__">__iadd__</a></b> (<i>self</i>, QChar&#160;<i>c</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-2">__iadd__</a></b> (<i>self</i>, QChar.SpecialCharacter&#160;<i>c</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-3">__iadd__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-4">__iadd__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-5">__iadd__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__imul__">__imul__</a></b> (<i>self</i>, int&#160;<i>m</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__le__">__le__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__le__-2">__le__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__le__-3">__le__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />int <b><a href="qstring.html#__len__">__len__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__lt__">__lt__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__lt__-2">__lt__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__lt__-3">__lt__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__mul__">__mul__</a></b> (<i>self</i>, int&#160;<i>m</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__">__ne__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__-2">__ne__</a></b> (<i>self</i>, QLatin1String&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__-3">__ne__</a></b> (<i>self</i>, QByteArray&#160;<i>s</i>)</li><li><div class="fn" />object <b><a href="qstring.html#__str__">__str__</a></b> (<i>self</i>)</li><li><div class="fn" />object <b><a href="qstring.html#__unicode__">__unicode__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>A Python string or unicode object
    may be used whenever a
    <a href="qstring.html">QString</a>
    is expected.</p>
  <p>The QString class provides a Unicode character string.</p>
<p>QString stores a string of 16-bit <a href="qchar.html">QChar</a>s, where each <a href="qchar.html">QChar</a> stores one Unicode 4.0 character. <a href="unicode.html">Unicode</a> is an international standard that supports most of the writing systems in use today. It is a superset of ASCII and Latin-1 (ISO 8859-1), and all the ASCII/Latin-1 characters are available at the same code positions.</p>
<p>Behind the scenes, QString uses <a href="shclass.html#implicit-sharing">implicit sharing</a> (copy-on-write) to reduce memory usage and to avoid the needless copying of data. This also helps reduce the inherent overhead of storing 16-bit characters instead of 8-bit characters.</p>
<p>In addition to QString, Qt also provides the <a href="qbytearray.html">QByteArray</a> class to store raw bytes and traditional 8-bit '\0'-terminated strings. For most purposes, QString is the class you want to use. It is used throughout the Qt API, and the Unicode support ensures that your applications will be easy to translate if you want to expand your application's market at some point. The two main cases where <a href="qbytearray.html">QByteArray</a> 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 QString is simply to pass a <tt>const char *</tt> to its constructor. For example, the following code creates a QString of size 5 containing the data "Hello":</p>
<pre>
    QString str = "Hello";
</pre>
<p>QString converts the <tt>const char *</tt> data into Unicode using <a href="qstring.html#fromAscii">fromAscii</a>(). By default, <a href="qstring.html#fromAscii">fromAscii</a>() treats character above 128 as Latin-1 characters, but this can be changed by calling <a href="qtextcodec.html#setCodecForCStrings">QTextCodec.setCodecForCStrings</a>().</p>
<p>In all of the QString methods that take <tt>const char *</tt> parameters, the <tt>const char *</tt> is interpreted as a classic C-style '\0'-terminated string. It is legal for the <tt>const char *</tt> parameter to be 0.</p>
<p>You can also provide string data as an array of <a href="qchar.html">QChar</a>s:</p>
<pre>
    static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 };
    QString str(data, 4);
</pre>
<p>QString makes a deep copy of the <a href="qchar.html">QChar</a> 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="qstring.html#fromRawData">QString.fromRawData</a>() instead.)</p>
<p>Another approach is to set the size of the string using <a href="qstring.html#resize">resize</a>() and to initialize the data character per character. QString uses 0-based indexes, just like C++ arrays. To access the character at a particular index position, you can use operator[](). On non-const strings, operator[]() returns a reference to a character that can be used on the left side of an assignment. For example:</p>
<pre>
    QString str;
    str.resize(4);
    str[0] = QChar('U');
    str[1] = QChar('n');
    str[2] = QChar(0x10e3);
    str[3] = QChar(0x03a3);
</pre>
<p>For read-only access, an alternative syntax is to use <a href="qstring.html#at">at</a>():</p>
<pre>
    for (int i = 0; i &lt; str.size(); ++i) {
        if (str.at(i) &gt;= QChar('a') &amp;&amp; str.at(i) &lt;= QChar('f'))
            qDebug() &lt;&lt; "Found character in range [a-f]";
    }
</pre>
<p><a href="qstring.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 several characters at a time, use <a href="qstring.html#left">left</a>(), <a href="qstring.html#right">right</a>(), or <a href="qstring.html#mid">mid</a>().</p>
<p>A QString can embed '\0' characters (<a href="qchar.html#SpecialCharacter-enum">QChar.null</a>). The <a href="qstring.html#size">size</a>() function always returns the size of the whole string, including embedded '\0' characters.</p>
<p>After a call to <a href="qstring.html#resize">resize</a>(), newly allocated characters have undefined values. To set all the characters in the string to a particular value, call <a href="qstring.html#fill">fill</a>().</p>
<p>QString provides dozens of overloads designed to simplify string usage. For example, if you want to compare a QString with a string literal, you can write code like this and it will work as expected:</p>
<pre>
    if (str == "auto" || str == "extern"
            || str == "static" || str == "register") {
        ...
    }
</pre>
<p>You can also pass string literals to functions that take QStrings and the QString(const char *) constructor will be invoked. Similarily, you can pass a QString to a function that takes a <tt>const char *</tt> using the <a href="qtcore.html#qPrintable">qPrintable</a>() macro which returns the given QString as a <tt>const char *</tt>. This is equivalent to calling &lt;QString&gt;.<a href="qstring.html#toAscii">toAscii</a>().<a href="qstring.html#constData">constData</a>().</p>
<p>QString provides the following basic functions for modifying the character data: <a href="qstring.html#append">append</a>(), <a href="qstring.html#prepend">prepend</a>(), <a href="qstring.html#insert">insert</a>(), <a href="qstring.html#replace">replace</a>(), and <a href="qstring.html#remove">remove</a>(). For example:</p>
<pre>
    QString str = "and";
    str.prepend("rock ");           // str == "rock and"
    str.append(" roll");            // str == "rock and roll"
    str.replace(5, 3, "&amp;");         // str == "rock &amp; roll"
</pre>
<p>The <a href="qstring.html#replace">replace</a>() and <a href="qstring.html#remove">remove</a>() functions' first two arguments are the position from which to start erasing and the number of characters that should be erased.</p>
<p>A frequent requirement is to remove whitespace characters from a string ('\n', '\t', ' ', etc.). If you want to remove whitespace from both ends of a QString, use <a href="qstring.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 string, use <a href="qstring.html#simplified">simplified</a>().</p>
<p>If you want to find all occurrences of a particular character or substring in a QString, use <a href="qstring.html#indexOf">indexOf</a>() or <a href="qstring.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>
    QString str = "We must be &lt;b&gt;bold&lt;/b&gt;, very &lt;b&gt;bold&lt;/b&gt;";
    int j = 0;
    while ((j = str.indexOf("&lt;b&gt;", j)) != -1) {
        qDebug() &lt;&lt; "Found &lt;b&gt; tag at index position" &lt;&lt; j;
        ++j;
    }
</pre>
<p>If you want to see if a QString starts or ends with a particular substring use <a href="qstring.html#startsWith">startsWith</a>() or <a href="qstring.html#endsWith">endsWith</a>(). If you simply want to check whether a QString contains a particular character or substring, use <a href="qstring.html#contains">contains</a>(). If you want to find out how many times a particular character or substring occurs in the string, use <a href="qstring.html#count">count</a>().</p>
<p>QString provides many functions for converting numbers into strings and strings into numbers. See the <a href="qstring.html#arg">arg</a>() functions, the <a href="qstring.html#setNum">setNum</a>() functions, the <a href="qstring.html#number">number</a>() static functions, and the <a href="qstring.html#toInt">toInt</a>(), <a href="qstring.html#toDouble">toDouble</a>(), and similar functions.</p>
<p>To get an upper- or lowercase version of a string use <a href="qstring.html#toUpper">toUpper</a>() or <a href="qstring.html#toLower">toLower</a>().</p>
<p>If you want to replace all occurrences of a particular substring with another, use one of the two-parameter <a href="qstring.html#replace">replace</a>() overloads.</p>
<p>QStrings 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 Unicode 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>Lists of strings are handled by the <a href="qstringlist.html">QStringList</a> class. You can split a string into a list of strings using <a href="qstring.html#split">split</a>(), and join a list of strings into a single string with an optional separator using <a href="qstringlist.html#join">QStringList.join</a>(). You can obtain a list of strings from a string list that contain a particular substring or that match a particular <a href="qregexp.html">QRegExp</a> using <a href="qlist-qt3.html#find">QStringList.find</a>().</p>
<p>If you are building a QString gradually and know in advance approximately how many characters the QString will contain, you can call <a href="qstring.html#reserve">reserve</a>(), asking QString to preallocate a certain amount of memory. You can also call <a href="qstring.html#capacity">capacity</a>() to find out how much memory QString actually allocated.</p>
<p>To obtain a pointer to the actual character data, call <a href="qstring.html#data">data</a>() or <a href="qstring.html#constData">constData</a>(). These functions return a pointer to the beginning of the <a href="qchar.html">QChar</a> data. The pointer is guaranteed to remain valid until a non-const function is called on the QString.</p>
<a id="conversions-between-8-bit-strings-and-unicode-strings" name="conversions-between-8-bit-strings-and-unicode-strings" />
<h3>Conversions between 8-bit strings and Unicode strings</h3>
<p>QString provides the following four functions that return a <tt>const char *</tt> version of the string as <a href="qbytearray.html">QByteArray</a>: <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), and <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>().</p>
<ul>
<li><a href="qstring.html#toAscii">toAscii</a>() returns an ASCII encoded 8-bit string.</li>
<li><a href="qstring.html#toLatin1">toLatin1</a>() returns a Latin-1 (ISO 8859-1) encoded 8-bit string.</li>
<li><a href="qstring.html#toUtf8">toUtf8</a>() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of ASCII that supports the entire Unicode character set through multibyte sequences.</li>
<li><a href="qstring.html#toLocal8Bit">toLocal8Bit</a>() returns an 8-bit string using the system's local encoding.</li>
</ul>
<p>To convert from one of these encodings, QString provides <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>(). Other encodings are supported through <a href="qtextcodec.html">QTextCodec</a>.</p>
<p>As mentioned above, QString provides a lot of functions and operators that make it easy to interoperate with <tt>const char *</tt> strings. This functionaly is a double-edged sword: It makes QString more convenient to use if all strings are ASCII or Latin-1, but there is always the risk that an implicit conversion from or to <tt>const char *</tt> is done using the wrong 8-bit encoding. To minimize these risks, you can turn off these implicit conversions by defining these two preprocessor symbols:</p>
<ul>
<li><tt>QT_NO_CAST_FROM_ASCII</tt> disables automatic conversions from ASCII to Unicode.</li>
<li><tt>QT_NO_CAST_TO_ASCII</tt> disables automatic conversion from QString to ASCII.</li>
</ul>
<p>One way to define these prepocessor symbols globally for your application is to add the following entry to your <a href="qmake-project-files.html">qmake project file</a>:</p>
<pre>
    DEFINES += QT_NO_CAST_FROM_ASCII \
               QT_NO_CAST_TO_ASCII
</pre>
<p>You then need to explicitly call <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), or <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>() to construct a QString from an 8-bit string, or use the lightweight <a href="qlatin1string.html">QLatin1String</a> class, for example:</p>
<pre>
    QString url = QLatin1String("http://www.unicode.org/");
</pre>
<p>Similarly, you must call <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), or <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>() explicitly to convert the QString to an 8-bit string. (Other encodings are supported through <a href="qtextcodec.html">QTextCodec</a>.)</p>
<a id="note-for-c-programmers" name="note-for-c-programmers" />
<h3>Note for C programmers</h3>
<p>Due to C++'s type system and the fact that QString is <a href="shclass.html#implicitly-shared">implicitly shared</a>, QStrings may be treated like <tt>int</tt>s or other basic types. For example:</p>
<pre>
    QString boolToString(bool b)
    {
        QString result;
        if (b)
            result = "True";
        else
            result = "False";
        return result;
    }
</pre>
<p>The variable, result, is a normal variable allocated on the stack. When return is called, because we're returning by value, The copy constructor is called and a copy of the string is returned. (No actual copying takes place thanks to the implicit sharing.)</p>
<a id="distinction-between-null-and-empty-strings" name="distinction-between-null-and-empty-strings" />
<h3>Distinction between null and empty strings</h3>
<p>For historical reasons, QString distinguishes between a null string and an empty string. A <i>null</i> string is a string that is initialized using QString's default constructor or by passing (const char *)0 to the constructor. An <i>empty</i> string is any string with size 0. A null string is always empty, but an empty string isn't necessarily null:</p>
<pre>
        QString().isNull();             // returns true
        QString().isEmpty();            // returns true

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

        QString("abc").isNull();        // returns false
        QString("abc").isEmpty();       // returns false
</pre>
<p>All functions except <a href="qstring.html#isNull">isNull</a>() treat null strings the same as empty strings. For example, <a href="qstring.html#toAscii">toAscii</a>().<a href="qstring.html#constData">constData</a>() returns a pointer to a '\0' character for a null string (<i>not</i> a null pointer), and <a href="qstring.html#QString">QString</a>() compares equal to QString(""). We recommend that you always use <a href="qstring.html#isEmpty">isEmpty</a>() and avoid <a href="qstring.html#isNull">isNull</a>().</p>
<p>See also <a href="qstring.html#fromRawData">fromRawData</a>(), <a href="qchar.html">QChar</a>, <a href="qlatin1string.html">QLatin1String</a>, and <a href="qbytearray.html">QByteArray</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="NormalizationForm-enum" />QString.NormalizationForm</h3><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QString.NormalizationForm_D</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">Canonical Decomposition</td>
</tr>
<tr>
<td valign="top"><tt>QString.NormalizationForm_C</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">Canonical Decomposition followed by Canonical Composition</td>
</tr>
<tr>
<td valign="top"><tt>QString.NormalizationForm_KD</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
<td valign="top">Compatibility Decomposition</td>
</tr>
<tr>
<td valign="top"><tt>QString.NormalizationForm_KC</tt></td>
<td align="center" valign="top"><tt>3</tt></td>
<td valign="top">Compatibility Decomposition followed by Canonical Composition</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qstring.html#normalized">normalized</a>() and <a href="http://www.unicode.org/reports/tr15/">Unicode Standard Annex #15</a>.</p>
<h3 class="fn"><a name="SectionFlag-enum" />QString.SectionFlag</h3><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QString.SectionDefault</tt></td>
<td align="center" valign="top"><tt>0x00</tt></td>
<td valign="top">Empty fields are counted, leading and trailing separators are not included, and the separator is compared case sensitively.</td>
</tr>
<tr>
<td valign="top"><tt>QString.SectionSkipEmpty</tt></td>
<td align="center" valign="top"><tt>0x01</tt></td>
<td valign="top">Treat empty fields as if they don't exist, i.e. they are not considered as far as <i>start</i> and <i>end</i> are concerned.</td>
</tr>
<tr>
<td valign="top"><tt>QString.SectionIncludeLeadingSep</tt></td>
<td align="center" valign="top"><tt>0x02</tt></td>
<td valign="top">Include the leading separator (if any) in the result string.</td>
</tr>
<tr>
<td valign="top"><tt>QString.SectionIncludeTrailingSep</tt></td>
<td align="center" valign="top"><tt>0x04</tt></td>
<td valign="top">Include the trailing separator (if any) in the result string.</td>
</tr>
<tr>
<td valign="top"><tt>QString.SectionCaseInsensitiveSeps</tt></td>
<td align="center" valign="top"><tt>0x08</tt></td>
<td valign="top">Compare the separator case-insensitively.</td>
</tr>
</table>
<br />
<br />
<p>The SectionFlags type is a typedef for <a href="qflags.html">QFlags</a>&lt;SectionFlag&gt;. It stores an OR combination of SectionFlag values.</p>
<p>See also <a href="qstring.html#section">section</a>().</p>
<h3 class="fn"><a name="SplitBehavior-enum" />QString.SplitBehavior</h3><p>This enum specifies how <a href="qstring.html#split">split</a>() should behave with respect to empty strings.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QString.KeepEmptyParts</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">If a field is empty, keep it in the result.</td>
</tr>
<tr>
<td valign="top"><tt>QString.SkipEmptyParts</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">If a field is empty, don't include it in the result.</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qstring.html#split">split</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QString" />QString.__init__ (<i>self</i>)</h3><p>Constructs a null string. Null strings are also empty.</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QString" />QString.__init__ (<i>self</i>, <a href="qkeysequence.html">QKeySequence</a>)</h3><p>This method is only available if the QtGui module is imported.</p><p>Constructs a null string. Null strings are also empty.</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QString-2" />QString.__init__ (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><p>Constructs a string initialized with the first <i>size</i> characters of the <a href="qchar.html">QChar</a> array <i>unicode</i>.</p>
<p><a href="qstring.html">QString</a> makes a deep copy of the string data.</p>
<h3 class="fn"><a name="QString-3" />QString.__init__ (<i>self</i>, int&#160;<i>size</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><p>Constructs a string of size 1 containing the character <i>ch</i>.</p>
<h3 class="fn"><a name="QString-4" />QString.__init__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><p>Constructs a string of size <i>size</i> with every character set to <i>ch</i>.</p>
<p>See also <a href="qstring.html#fill">fill</a>().</p>
<h3 class="fn"><a name="QString-5" />QString.__init__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>latin1</i>)</h3><p>Constructs a copy of the Latin-1 string <i>str</i>.</p>
<p>See also <a href="qstring.html#fromLatin1">fromLatin1</a>().</p>
<h3 class="fn"><a name="QString-6" />QString.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>a</i>)</h3><p>Constructs a copy of <i>other</i>.</p>
<p>This operation takes <a href="containers.html#constant-time">constant time</a>, because <a href="qstring.html">QString</a> is <a href="shclass.html#implicitly-shared">implicitly shared</a>. This makes returning a <a href="qstring.html">QString</a> from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes <a href="containers.html#linear-time">linear time</a>.</p>
<p>See also <a href="qstring.html#operator-eq">operator=</a>().</p>
<h3 class="fn"><a name="QString-7" />QString.__init__ (<i>self</i>, <a href="quuid.html">QUuid</a>)</h3><p>Constructs a string initialized with the ASCII string <i>str</i>. <i>str</i> is converted to Unicode using <a href="qstring.html#fromAscii">fromAscii</a>().</p>
<p>You can disable this constructor by defining <tt>QT_NO_CAST_FROM_ASCII</tt> when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through <a href="qobject.html#tr">QObject.tr</a>(), for example.</p>
<p>See also <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>(), and <a href="qstring.html#fromUtf8">fromUtf8</a>().</p>
<h3 class="fn"><a name="append" /><a href="qstring.html">QString</a> QString.append (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><p>Appends the string <i>str</i> onto the end of this string.</p>
<p>Example:</p>
<pre>
    QString x = "free";
    QString y = "dom";
    x.append(y);
    // x == "freedom"
</pre>
<p>This is the same as insert(<a href="qstring.html#size">size</a>(), <i>str</i>).</p>
<p>This operation is typically very fast (<a href="containers.html#constant-time">constant time</a>), because <a href="qstring.html">QString</a> preallocates extra space at the end of the string data so it can grow without reallocating the entire string each time.</p>
<p>See also <a href="qstring.html#operator-2b-eq">operator+=</a>(), <a href="qstring.html#prepend">prepend</a>(), and <a href="qstring.html#insert">insert</a>().</p>
<h3 class="fn"><a name="append-2" /><a href="qstring.html">QString</a> QString.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 Latin-1 string <i>str</i> to this string.</p>
<h3 class="fn"><a name="append-3" /><a href="qstring.html">QString</a> QString.append (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Appends the byte array <i>ba</i> to this string. <i>ba</i> is converted to Unicode using <a href="qstring.html#fromAscii">fromAscii</a>().</p>
<p>You can disable this function by defining <tt>QT_NO_CAST_FROM_ASCII</tt> when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through <a href="qobject.html#tr">QObject.tr</a>(), for example.</p>
<h3 class="fn"><a name="append-4" /><a href="qstring.html">QString</a> QString.append (<i>self</i>, <a href="qbytearray.html">QByteArray</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 string. <i>str</i> is converted to Unicode using <a href="qstring.html#fromAscii">fromAscii</a>().</p>
<p>You can disable this function by defining <tt>QT_NO_CAST_FROM_ASCII</tt> when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through <a href="qobject.html#tr">QObject.tr</a>(), for example.</p>
<h3 class="fn"><a name="arg" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, int&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, <a href="qchar.html">QChar</a>&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</h3><p>This function returns a copy of this string where <i>a</i> replaces the lowest numbered occurrence of <tt>%1</tt>, <tt>%2</tt>, ..., <tt>%99</tt>.</p>
<p>The <i>fieldWidth</i> value specifies the minimum amount of space that <i>a</i> is padded to and filled with the character <i>fillChar</i>. A positive value will produce right-aligned text, whereas a negative value will produce left-aligned text.</p>
<p>The following example shows how we could create a 'status' string when processing a list of files:</p>
<pre>
    QString status = QString("Processing file %1 of %2: %3")
                        .arg(i)         // current file's number
                        .arg(total)     // number of files to process
                        .arg(fileName); // current file's name
</pre>
<p>It is generally fine to use file names and numbers as we have done in the example above. But note that using arg() to construct natural language sentences does not usually translate well into other languages because sentence structure and word order often differ between languages.</p>
<p>If there is no place marker (<tt>%1</tt>, <tt>%2</tt>, etc.), a warning message is output and the result is undefined. Note that only placeholders between <tt>%1</tt> and <tt>%99</tt> are supported.</p>
<h3 class="fn"><a name="arg-2" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, float&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, char&#160;<i>fmt</i>&#160;=&#160;'g', int&#160;<i>prec</i>&#160;=&#160;-1, <a href="qchar.html">QChar</a>&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This is the same as str.arg(<i>a1</i>).arg(<i>a2</i>), except that the strings are replaced in one pass. This can make a difference if <i>a1</i> contains e.g. <tt>%1</tt>:</p>
<pre>
    QString str = "%1 %2";
    str.arg("%1f", "Hello");        // returns "%1f Hello"
    str.arg("%1f").arg("Hello");    // returns "Hellof"
</pre>
<h3 class="fn"><a name="arg-3" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, long&#160;<i>a</i>, int&#160;<i>fieldwidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, <a href="qchar.html">QChar</a>&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This is the same as calling str.arg(<i>a1</i>).arg(<i>a2</i>).arg(<i>a3</i>), except that the strings are replaced in one pass.</p>
<h3 class="fn"><a name="arg-4" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, unsigned long&#160;<i>a</i>, int&#160;<i>fieldwidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, <a href="qchar.html">QChar</a>&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This is the same as calling str.arg(<i>a1</i>).arg(<i>a2</i>).arg(<i>a3</i>).arg(<i>a4</i>), except that the strings are replaced in one pass.</p>
<h3 class="fn"><a name="arg-5" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, <a href="qchar.html">QChar</a>&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</h3><p>This is an overloaded member function, provided for convenience.</p>
<p><i>a</i> is expressed in base <i>base</i>, which is 10 by default and must be between 2 and 36.</p>
<p>The <i>fieldWidth</i> value specifies the minimum amount of space that <i>a</i> is padded to and filled with the character <i>fillChar</i>. A positive value will produce a right-aligned number, whereas a negative value will produce a left-aligned number.</p>
<p>The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of <i>a</i>. The conversion uses the default locale, set by QLocale.setDefaultLocale(). If no default locale was specified, the "C" locale is used. The 'L' flag is ignored if <i>base</i> is not 10.</p>
<pre>
    QString str;
    str = QString("Decimal 63 is %1 in hexadecimal")
            .arg(63, 0, 16);
    // str == "Decimal 63 is 3f in hexadecimal"

    QLocale.setDefaultLocale(QLocale.English, QLocale.UnitedStates);
    str = QString("%1 %L2 %L3")
            .arg(12345)
            .arg(12345)
            .arg(12345, 0, 16);
    // str == "12345 12,345 3039"
</pre>
<h3 class="fn"><a name="arg-6" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>a</i>, int&#160;<i>fieldWidth</i>&#160;=&#160;0, <a href="qchar.html">QChar</a>&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(32))</h3><p>This is an overloaded member function, provided for convenience.</p>
<p><i>base</i> is the base to use when converting the integer <i>a</i> into a string. <i>base</i> must be between 2 and 36, with 8 giving octal, 10 decimal, and 16 hexadecimal numbers.</p>
<h3 class="fn"><a name="arg-7" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>a1</i>, <a href="qstring.html">QString</a>&#160;<i>a2</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>The <i>fieldWidth</i> value specifies the minimum amount of space that <i>a</i> is padded to and filled with the character <i>fillChar</i>. A positive value will produce a right-aligned number, whereas a negative value will produce a left-aligned number.</p>
<p><i>a</i> is expressed in base <i>base</i>, which is 10 by default and must be between 2 and 36.</p>
<p>The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of <i>a</i>. The conversion uses the default locale. The default locale is determined from the system's locale settings at application startup. It can be changed using <a href="qlocale.html#setDefault">QLocale.setDefault</a>(). The 'L' flag is ignored if <i>base</i> is not 10.</p>
<pre>
    QString str;
    str = QString( "Decimal 63 is %1 in hexadecimal" )
            .arg( 63, 0, 16 );
    // str == "Decimal 63 is 3f in hexadecimal"

    QLocale.setDefault(QLocale.English, QLocale.UnitedStates);
    str = QString( "%1 %L2 %L3" )
            .arg( 12345 )
            .arg( 12345 )
            .arg( 12345, 0, 16 );
    // str == "12345 12,345 3039"
</pre>
<h3 class="fn"><a name="arg-8" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>a1</i>, <a href="qstring.html">QString</a>&#160;<i>a2</i>, <a href="qstring.html">QString</a>&#160;<i>a3</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p><i>base</i> is the base to use when converting the integer <i>a</i> into a string. <i>base</i> must be between 2 and 36, with 8 giving octal, 10 decimal, and 16 hexadecimal numbers.</p>
<h3 class="fn"><a name="arg-9" /><a href="qstring.html">QString</a> QString.arg (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>a1</i>, <a href="qstring.html">QString</a>&#160;<i>a2</i>, <a href="qstring.html">QString</a>&#160;<i>a3</i>, <a href="qstring.html">QString</a>&#160;<i>a4</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p><i>base</i> is the base to use when converting the integer <i>a</i> into a string. <i>base</i> must be between 2 and 36, with 8 giving octal, 10 decimal, and 16 hexadecimal numbers.</p>
<h3 class="fn"><a name="at" /><a href="qchar.html">QChar</a> QString.at (<i>self</i>, int&#160;<i>i</i>)</h3><p>Returns the character at index position <i>i</i> in the string.</p>
<p><i>i</i> must be a valid index position in the string (i.e., 0 &lt;= <i>i</i> &lt; <a href="qstring.html#size">size</a>()).</p>
<p>See also <a href="qstring.html#operator-5b-5d">operator[]</a>().</p>
<h3 class="fn"><a name="capacity" />int QString.capacity (<i>self</i>)</h3><p>Returns the maximum number of characters that can be stored in the string without forcing a reallocation.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qstring.html">QString</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many characters are in the string, call <a href="qstring.html#size">size</a>().</p>
<p>See also <a href="qstring.html#reserve">reserve</a>() and <a href="qstring.html#squeeze">squeeze</a>().</p>
<h3 class="fn"><a name="chop" />QString.chop (<i>self</i>, int&#160;<i>n</i>)</h3><p>Removes <i>n</i> characters from the end of the string.</p>
<p>If <i>n</i> is greater than <a href="qstring.html#size">size</a>(), the result is an empty string.</p>
<p>Example:</p>
<pre>
    QString str("LOGOUT\r\n");
    str.chop(2);
    // str == "LOGOUT"
</pre>
<p>If you want to remove characters from the <i>beginning</i> of the string, use <a href="qstring.html#remove">remove</a>() instead.</p>
<p>See also <a href="qstring.html#truncate">truncate</a>(), <a href="qstring.html#resize">resize</a>(), and <a href="qstring.html#remove">remove</a>().</p>
<h3 class="fn"><a name="clear" />QString.clear (<i>self</i>)</h3><p>Clears the contents of the string and makes it empty.</p>
<p>See also <a href="qstring.html#resize">resize</a>() and <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="compare" />int QString.compare (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><p>Lexically compares <i>s1</i> with <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p>
<p>The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with <a href="qstring.html#localeAwareCompare">localeAwareCompare</a>().</p>
<pre>
    int x = QString.compare("auto", "auto");   // x == 0
    int y = QString.compare("auto", "car");    // y &lt; 0
    int z = QString.compare("car", "auto");    // z &gt; 0
</pre>
<p>See also <a href="qstring.html#localeAwareCompare">localeAwareCompare</a>(), <a href="qstring.html#operator-eq-eq">operator==</a>(), <a href="qstring.html#operator-lt">operator&lt;</a>(), and <a href="qstring.html#operator-gt">operator&gt;</a>().</p>
<h3 class="fn"><a name="compare-2" />int QString.compare (<a href="qstring.html">QString</a>&#160;<i>s1</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Same as compare(*this, <i>other</i>).</p>
<h3 class="fn"><a name="contains" />bool QString.contains (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns true if this string contains an occurrence of the string <i>str</i>; otherwise returns false.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<p>Example:</p>
<pre>
    QString str = "Peter Pan";
    str.contains("peter", Qt.CaseInsensitive);    // returns true
</pre>
<p>See also <a href="qstring.html#indexOf">indexOf</a>() and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="contains-2" />bool QString.contains (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="contains-3" />bool QString.contains (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>rx</i>)</h3><h3 class="fn"><a name="count" />int QString.count (<i>self</i>)</h3><p>Returns the number of (potentially overlapping) occurrences of the string <i>str</i> in this string.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<p>See also <a href="qstring.html#contains">contains</a>() and <a href="qstring.html#indexOf">indexOf</a>().</p>
<h3 class="fn"><a name="count-2" />int QString.count (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the number of occurrences of character <i>ch</i> in the string.</p>
<h3 class="fn"><a name="count-3" />int QString.count (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the number of times the regular expression <i>rx</i> matches in the string.</p>
<p>This function counts overlapping matches, so in the example below, there are four instances of "ana" or "ama":</p>
<pre>
    QString str = "banana and panama";
    str.contains(QRegExp("a[nm]a"));    // returns 4
</pre>
<h3 class="fn"><a name="count-4" />int QString.count (<i>self</i>, <a href="qregexp.html">QRegExp</a>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Same as <a href="qstring.html#size">size</a>().</p>
<h3 class="fn"><a name="endsWith" />bool QString.endsWith (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns true if the string ends with <i>s</i>; otherwise returns false.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<pre>
    QString str = "Bananas";
    str.endsWith("anas");         // returns true
    str.endsWith("pple");         // returns false
</pre>
<p>See also <a href="qstring.html#startsWith">startsWith</a>().</p>
<h3 class="fn"><a name="endsWith-2" />bool QString.endsWith (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="endsWith-3" />bool QString.endsWith (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="fill" /><a href="qstring.html">QString</a> QString.fill (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Sets every character in the string to character <i>ch</i>. If <i>size</i> is different from -1 (the default), the string is resized to <i>size</i> beforehand.</p>
<p>Example:</p>
<pre>
    QString str = "Berlin";
    str.fill("z");
    // str == "zzzzzz"

    str.fill("A", 2);
    // str == "AA"
</pre>
<p>See also <a href="qstring.html#resize">resize</a>().</p>
<h3 class="fn"><a name="fromAscii" /><a href="qstring.html">QString</a> QString.fromAscii (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> characters of the 8-bit ASCII string <i>str</i>.</p>
<p>If <i>size</i> is -1 (the default), it is taken to be qstrlen(<i>str</i>).</p>
<p>If a codec has been set using <a href="qtextcodec.html#setCodecForCStrings">QTextCodec.setCodecForCStrings</a>(), it is used to convert <i>str</i> to Unicode; otherwise this function does the same as <a href="qstring.html#fromLatin1">fromLatin1</a>().</p>
<p>See also <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>().</p>
<h3 class="fn"><a name="fromLatin1" /><a href="qstring.html">QString</a> QString.fromLatin1 (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> characters of the Latin-1 string <i>str</i>.</p>
<p>If <i>size</i> is -1 (the default), it is taken to be qstrlen(<i>str</i>).</p>
<p>See also <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>().</p>
<h3 class="fn"><a name="fromLocal8Bit" /><a href="qstring.html">QString</a> QString.fromLocal8Bit (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> characters of the 8-bit string <i>str</i>.</p>
<p>If <i>size</i> is -1 (the default), it is taken to be qstrlen(<i>str</i>).</p>
<p><a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>() is used to perform the conversion from Unicode.</p>
<p>See also <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), and <a href="qstring.html#fromUtf8">fromUtf8</a>().</p>
<h3 class="fn"><a name="fromUtf8" /><a href="qstring.html">QString</a> QString.fromUtf8 (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> bytes of the UTF-8 string <i>str</i>.</p>
<p>If <i>size</i> is -1 (the default), it is taken to be qstrlen(<i>str</i>).</p>
<p>See also <a href="qstring.html#toUtf8">toUtf8</a>(), <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>().</p>
<h3 class="fn"><a name="indexOf" />int QString.indexOf (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, int&#160;<i>from</i>&#160;=&#160;0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns the index position of the first occurrence of the string <i>str</i> in this string, searching forward from index position <i>from</i>. Returns -1 if <i>str</i> is not found.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<p>Example:</p>
<pre>
    QString x = "sticky question";
    QString 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>If <i>from</i> is -1, the search starts at the last character; if it is -2, at the next to last character and so on.</p>
<p>See also <a href="qstring.html#lastIndexOf">lastIndexOf</a>(), <a href="qstring.html#contains">contains</a>(), and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="indexOf-2" />int QString.indexOf (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the index position of the first occurrence of the character <i>ch</i> in the string, searching forward from index position <i>from</i>. Returns -1 if <i>ch</i> could not be found.</p>
<h3 class="fn"><a name="indexOf-3" />int QString.indexOf (<i>self</i>, <a href="qregexp.html">QRegExp</a>, 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 match of the regular expression <i>rx</i> in the string, searching forward from index position <i>from</i>. Returns -1 if <i>rx</i> didn't match anywhere.</p>
<p>Example:</p>
<pre>
    QString str = "the minimum";
    str.indexOf(QRegExp("m[aeiou]"), 0);       // returns 4
</pre>
<h3 class="fn"><a name="insert" /><a href="qstring.html">QString</a> QString.insert (<i>self</i>, int&#160;<i>i</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><p>Inserts the string <i>str</i> at index position <i>i</i> and returns a reference to this string.</p>
<p>Example:</p>
<pre>
    QString str = "Meal";
    str.insert(1, QString("ontr"));
    // str == "Montreal"
</pre>
<p>If <i>i</i> is greater than <a href="qstring.html#size">size</a>(), the array is first extended using <a href="qstring.html#resize">resize</a>().</p>
<p>See also <a href="qstring.html#append">append</a>(), <a href="qstring.html#prepend">prepend</a>(), <a href="qstring.html#replace">replace</a>(), and <a href="qstring.html#remove">remove</a>().</p>
<h3 class="fn"><a name="insert-2" /><a href="qstring.html">QString</a> QString.insert (<i>self</i>, int&#160;<i>i</i>, <a href="qchar.html">QChar</a>&#160;<i>uc</i>, int&#160;<i>len</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Inserts the Latin-1 string <i>str</i> at index position <i>i</i>.</p>
<h3 class="fn"><a name="insert-3" /><a href="qstring.html">QString</a> QString.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 first <i>size</i> characters of the <a href="qchar.html">QChar</a> array <i>unicode</i> at index position <i>i</i> in the string.</p>
<h3 class="fn"><a name="insert-4" /><a href="qstring.html">QString</a> QString.insert (<i>self</i>, int&#160;<i>i</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Inserts <i>ch</i> at index position <i>i</i> in the string.</p>
<h3 class="fn"><a name="isEmpty" />bool QString.isEmpty (<i>self</i>)</h3><p>Returns true if the string has no characters; otherwise returns false.</p>
<p>Example:</p>
<pre>
    QString().isEmpty();            // returns true
    QString("").isEmpty();          // returns true
    QString("x").isEmpty();         // returns false
    QString("abc").isEmpty();       // returns false
</pre>
<p>See also <a href="qstring.html#size">size</a>().</p>
<h3 class="fn"><a name="isNull" />bool QString.isNull (<i>self</i>)</h3><p>Returns true if this string is null; otherwise returns false.</p>
<p>Example:</p>
<pre>
    QString().isNull();             // returns true
    QString("").isNull();           // returns false
    QString("abc").isNull();        // returns false
</pre>
<p>Qt makes a distinction between null strings and empty strings for historical reasons. For most applications, what matters is whether or not a string contains any data, and this can be determined using <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="isRightToLeft" />bool QString.isRightToLeft (<i>self</i>)</h3><h3 class="fn"><a name="isSimpleText" />bool QString.isSimpleText (<i>self</i>)</h3><h3 class="fn"><a name="lastIndexOf" />int QString.lastIndexOf (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, int&#160;<i>from</i>&#160;=&#160;-1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns the index position of the last occurrence of the string <i>str</i> in this string, searching backward from index position <i>from</i>. If <i>from</i> is -1 (the default), the search starts at the last character; if <i>from</i> is -2, at the next to last character and so on. Returns -1 if <i>str</i> is not found.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<p>Example:</p>
<pre>
    QString x = "crazy azimuths";
    QString y = "az";
    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="qstring.html#indexOf">indexOf</a>(), <a href="qstring.html#contains">contains</a>(), and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="lastIndexOf-2" />int QString.lastIndexOf (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, int&#160;<i>from</i>&#160;=&#160;-1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the index position of the last occurrence of the character <i>ch</i>, searching backward from position <i>from</i>.</p>
<h3 class="fn"><a name="lastIndexOf-3" />int QString.lastIndexOf (<i>self</i>, <a href="qregexp.html">QRegExp</a>, 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 match of the regular expression <i>rx</i> in the string, searching backward from index position <i>from</i>. Returns -1 if <i>rx</i> didn't match anywhere.</p>
<p>Example:</p>
<pre>
    QString str = "the minimum";
    str.lastIndexOf(QRegExp("m[aeiou]"));      // returns 8
</pre>
<h3 class="fn"><a name="left" /><a href="qstring.html">QString</a> QString.left (<i>self</i>, int&#160;<i>len</i>)</h3><p>Returns a substring that contains the <i>len</i> leftmost characters of the string.</p>
<p>The entire string is returned if <i>len</i> is greater than <a href="qstring.html#size">size</a>() or less than zero.</p>
<pre>
    QString x = "Pineapple";
    QString y = x.left(4);      // y == "Pine"
</pre>
<p>See also <a href="qstring.html#right">right</a>(), <a href="qstring.html#mid">mid</a>(), and <a href="qstring.html#startsWith">startsWith</a>().</p>
<h3 class="fn"><a name="leftJustified" /><a href="qstring.html">QString</a> QString.leftJustified (<i>self</i>, int&#160;<i>width</i>, <a href="qchar.html">QChar</a>&#160;<i>fill</i>&#160;=&#160;QLatin1Char(32), bool&#160;<i>trunc</i>&#160;=&#160;False)</h3><p>Returns a string of <a href="qstring.html#size">size</a>() <i>width</i> that contains this string padded by the <i>fill</i> character.</p>
<p>If <i>truncate</i> is false and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then the returned string is a copy of the string.</p>
<p>If <i>truncate</i> is true and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then any characters in a copy of the string after position <i>width</i> are removed, and the copy is returned.</p>
<pre>
    QString s = "apple";
    QString t = s.leftJustified(8, '.');        // t == "apple..."
</pre>
<p>See also <a href="qstring.html#rightJustified">rightJustified</a>().</p>
<h3 class="fn"><a name="length" />int QString.length (<i>self</i>)</h3><p>Same as <a href="qstring.html#size">size</a>().</p>
<p>See also <a href="qstring-qt3.html#setLength">setLength</a>().</p>
<h3 class="fn"><a name="localeAwareCompare" />int QString.localeAwareCompare (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><p>Compares <i>s1</i> with <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p>
<p>The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.</p>
<p>See also <a href="qstring.html#compare">compare</a>() and <a href="qtextcodec-qt3.html#locale">QTextCodec.locale</a>().</p>
<h3 class="fn"><a name="localeAwareCompare-2" />int QString.localeAwareCompare (<a href="qstring.html">QString</a>&#160;<i>s1</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Same as localeAwareCompare(*this, <i>other</i>).</p>
<h3 class="fn"><a name="mid" /><a href="qstring.html">QString</a> QString.mid (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>&#160;=&#160;-1)</h3><p>Returns a string that contains the <i>len</i> characters of this string, starting at position <i>i</i>.</p>
<p>Returns an empty string if index <i>i</i> exceeds the length of the string. If there are less than <i>len</i> characters available in the string starting at position <i>i</i>, or if <i>len</i> is -1 (the default), the function returns all characters that are available from position <i>i</i>.</p>
<p>Example:</p>
<pre>
    QString x = "Nine pineapples";
    QString y = x.mid(5, 4);            // y == "pine"
    QString z = x.mid(5);               // z == "pineapples"
</pre>
<p>See also <a href="qstring.html#left">left</a>() and <a href="qstring.html#right">right</a>().</p>
<h3 class="fn"><a name="normalized" /><a href="qstring.html">QString</a> QString.normalized (<i>self</i>, <a href="qstring.html#NormalizationForm-enum">NormalizationForm</a>&#160;<i>mode</i>)</h3><p>Returns the string in the given Unicode normalization <i>form</i>.</p>
<h3 class="fn"><a name="normalized-2" /><a href="qstring.html">QString</a> QString.normalized (<i>self</i>, <a href="qstring.html#NormalizationForm-enum">NormalizationForm</a>&#160;<i>mode</i>, <a href="qchar.html#UnicodeVersion-enum">QChar.UnicodeVersion</a>&#160;<i>version</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the string in the given Unicode normalization <i>form</i>, according to the given <i>version</i> of the Unicode standard.</p>
<h3 class="fn"><a name="number" /><a href="qstring.html">QString</a> QString.number (int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns a string equivalent of the number <i>n</i> to base <i>base</i>, which is 10 by default and must be between 2 and 36.</p>
<pre>
    long a = 63;
    QString str = QString.number(a, 16);             // str == "3f"
    QString str = QString.number(a, 16).upper();     // str == "3F"
</pre>
<p>See also <a href="qstring.html#setNum">setNum</a>().</p>
<h3 class="fn"><a name="number-2" /><a href="qstring.html">QString</a> QString.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>
<h3 class="fn"><a name="number-3" /><a href="qstring.html">QString</a> QString.number (long, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="number-4" /><a href="qstring.html">QString</a> QString.number (unsigned long, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="prepend" /><a href="qstring.html">QString</a> QString.prepend (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><p>Prepends the string <i>str</i> to the beginning of this string and returns a reference to this string.</p>
<p>Example:</p>
<pre>
    QString x = "ship";
    QString y = "air";
    x.prepend(y);
    // x == "airship"
</pre>
<p>See also <a href="qstring.html#append">append</a>() and <a href="qstring.html#insert">insert</a>().</p>
<h3 class="fn"><a name="prepend-2" /><a href="qstring.html">QString</a> QString.prepend (<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>Prepends the Latin-1 string <i>str</i> to this string.</p>
<h3 class="fn"><a name="prepend-3" /><a href="qstring.html">QString</a> QString.prepend (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Prepends the byte array <i>ba</i> to this string. <i>ba</i> is converted to Unicode using <a href="qstring.html#fromAscii">fromAscii</a>().</p>
<p>You can disable this function by defining <tt>QT_NO_CAST_FROM_ASCII</tt> when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through <a href="qobject.html#tr">QObject.tr</a>(), for example.</p>
<h3 class="fn"><a name="prepend-4" /><a href="qstring.html">QString</a> QString.prepend (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Prepends the string <i>str</i> to this string. <i>str</i> is converted to Unicode using <a href="qstring.html#fromAscii">fromAscii</a>().</p>
<p>You can disable this function by defining <tt>QT_NO_CAST_FROM_ASCII</tt> when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through <a href="qobject.html#tr">QObject.tr</a>(), for example.</p>
<h3 class="fn"><a name="push_back" />QString.push_back (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</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_back-2" />QString.push_back (<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>Same as append(<i>ch</i>).</p>
<h3 class="fn"><a name="push_front" />QString.push_front (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><p>This function is provided for STL compatibility. It is equivalent to prepend(<i>other</i>).</p>
<h3 class="fn"><a name="push_front-2" />QString.push_front (<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>Same as prepend(<i>ch</i>).</p>
<h3 class="fn"><a name="remove" /><a href="qstring.html">QString</a> QString.remove (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>)</h3><p>Removes <i>len</i> characters from the string, starting at index position <i>pos</i>, and returns a reference to the string.</p>
<p>If <i>pos</i> is within the string, but <i>pos</i> + <i>len</i> is beyond the end of the string, the string is truncated at position <i>pos</i>.</p>
<pre>
    QString str = "Montreal";
    str.remove(1, 4);
    // str == "Meal"
</pre>
<p>See also <a href="qstring.html#insert">insert</a>() and <a href="qstring.html#replace">replace</a>().</p>
<h3 class="fn"><a name="remove-2" /><a href="qstring.html">QString</a> QString.remove (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="remove-3" /><a href="qstring.html">QString</a> QString.remove (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="remove-4" /><a href="qstring.html">QString</a> QString.remove (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>rx</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Removes every occurrence of <i>str</i> in this string. Returns a reference to this string.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<p>This is the same as replace(<i>str</i>, "", <i>cs</i>).</p>
<h3 class="fn"><a name="replace" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>, <a href="qchar.html">QChar</a>&#160;<i>after</i>)</h3><p>Replaces <i>len</i> characters from index position <i>pos</i> with the string <i>after</i>, and returns a reference to this string.</p>
<p>Example:</p>
<pre>
    QString x = "Say yes!";
    QString y = "no";
    x.replace(4, 3, y);
    // x == "Say no!"
</pre>
<p>See also <a href="qstring.html#insert">insert</a>() and <a href="qstring.html#remove">remove</a>().</p>
<h3 class="fn"><a name="replace-2" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>, <a href="qchar.html">QChar</a>&#160;<i>s</i>, int&#160;<i>slen</i>)</h3><h3 class="fn"><a name="replace-3" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>len</i>, <a href="qstring.html">QString</a>&#160;<i>after</i>)</h3><h3 class="fn"><a name="replace-4" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>before</i>, <a href="qchar.html">QChar</a>&#160;<i>after</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="replace-5" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, <a href="qstring.html">QString</a>&#160;<i>after</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="replace-6" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>before</i>, <a href="qstring.html">QString</a>&#160;<i>after</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Replaces <i>len</i> characters from index position <i>pos</i> with the first <i>size</i> characters of the <a href="qchar.html">QChar</a> array <i>unicode</i>.</p>
<h3 class="fn"><a name="replace-7" /><a href="qstring.html">QString</a> QString.replace (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>rx</i>, <a href="qstring.html">QString</a>&#160;<i>after</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Replaces <i>len</i> characters from index position <i>pos</i> with the character <i>after</i>.</p>
<h3 class="fn"><a name="reserve" />QString.reserve (<i>self</i>, int&#160;<i>asize</i>)</h3><p>Attempts to allocate memory for at least <i>size</i> characters. If you know in advance how large the string will be, you can call this function, and if you resize the string 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="qstring.html">QString</a> will be a bit slower.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qstring.html">QString</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the string, call <a href="qstring.html#resize">resize</a>().</p>
<p>This function is useful for code that needs to build up a long string and wants to avoid repeated reallocation. In this example, we want to add to the string until some condition is true, and we're fairly sure that size is large enough to make a call to reserve() worthwhile:</p>
<pre>
    QString result;
    int len = 0;
    result.reserve(maxSize);
    while (...) {
        result[len++] = getNextChar(); // fill part of the space
    }
    result.squeeze();
</pre>
<p>See also <a href="qstring.html#squeeze">squeeze</a>() and <a href="qstring.html#capacity">capacity</a>().</p>
<h3 class="fn"><a name="resize" />QString.resize (<i>self</i>, int&#160;<i>size</i>)</h3><p>Sets the size of the string to <i>size</i> characters.</p>
<p>If <i>size</i> is greater than the current size, the string is extended to make it <i>size</i> characters long with the extra characters added to the end. The new characters are uninitialized.</p>
<p>If <i>size</i> is less than the current size, characters are removed from the end.</p>
<p>Example:</p>
<pre>
    QString str = "Hello world";
    str.resize(5);
    // str == "Hello"

    str.resize(8);
    // str == "Hello???" (where ? stands for any character)
</pre>
<p>If you want to append a certain number of identical characters to the string, use operator+=() as follows rather than resize():</p>
<pre>
    QString str = "Hello";
    str += QString(10, 'X');
    // str == "HelloXXXXXXXXXX"
</pre>
<p>If you want to expand the string so that it reaches a certain width and fill the new positions with a particular character, use <a href="qstring.html#leftJustified">leftJustified</a>():</p>
<pre>
    QString str = "Hello";
    str = str.leftJustified(10, ' ');
    // str == "Hello     "
</pre>
<p>See also <a href="qstring.html#truncate">truncate</a>() and <a href="qstring.html#reserve">reserve</a>().</p>
<h3 class="fn"><a name="right" /><a href="qstring.html">QString</a> QString.right (<i>self</i>, int&#160;<i>len</i>)</h3><p>Returns a substring that contains the <i>len</i> rightmost characters of the string.</p>
<p>The entire string is returned if <i>len</i> is greater than <a href="qstring.html#size">size</a>() or less than zero.</p>
<pre>
    QString x = "Pineapple";
    QString y = x.right(5);     // y == "apple"
</pre>
<p>See also <a href="qstring.html#left">left</a>(), <a href="qstring.html#mid">mid</a>(), and <a href="qstring.html#endsWith">endsWith</a>().</p>
<h3 class="fn"><a name="rightJustified" /><a href="qstring.html">QString</a> QString.rightJustified (<i>self</i>, int&#160;<i>width</i>, <a href="qchar.html">QChar</a>&#160;<i>fill</i>&#160;=&#160;QLatin1Char(32), bool&#160;<i>trunc</i>&#160;=&#160;False)</h3><p>Returns a string of <a href="qstring.html#size">size</a>() <i>width</i> that contains the <i>fill</i> character followed by the string.</p>
<p>If <i>truncate</i> is false and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then the returned string is a copy of the string.</p>
<p>If <i>truncate</i> is true and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then the resulting string is truncated at position <i>width</i>.</p>
<pre>
    QString str = "apple";
    str = str.rightJustified(8, '.');
    // str == "...apple"
</pre>
<p>See also <a href="qstring.html#leftJustified">leftJustified</a>().</p>
<h3 class="fn"><a name="section" /><a href="qstring.html">QString</a> QString.section (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>in_sep</i>, int&#160;<i>start</i>, int&#160;<i>end</i>&#160;=&#160;-1, <a href="qstring-sectionflags.html">SectionFlags</a>&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</h3><p>This function returns a section of the string.</p>
<p>This string is treated as a sequence of fields separated by the character, <i>sep</i>. The returned string consists of the fields from position <i>start</i> to position <i>end</i> inclusive. If <i>end</i> is not specified, all fields from position <i>start</i> to the end of the string are included. Fields are numbered 0, 1, 2, etc., counting from the left, and -1, -2, etc., counting from right to left.</p>
<p>The <i>flags</i> argument can be used to affect some aspects of the function's behavior, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see <a href="qstring.html#SectionFlag-enum">SectionFlags</a>.</p>
<pre>
    QString csv = "forename,middlename,surname,phone";
    QString str = csv.section(',', 2, 2);   // str == "surname"

    QString path = "/usr/local/bin/myapp"; // First field is empty
    QString str = path.section('/', 3, 4);  // str == "bin/myapp"
    QString str = path.section('/', 3, 3, SectionSkipEmpty); // str == "myapp"
</pre>
<p>If <i>start</i> or <i>end</i> is negative, we count fields from the right of the string, the right-most field being -1, the one from right-most field being -2, and so on.</p>
<pre>
    QString csv = "forename,middlename,surname,phone";
    QString str = csv.section(',', -3, -2);  // str == "middlename,surname"

    QString path = "/usr/local/bin/myapp"; // First field is empty
    QString str = path.section('/', -1); // str == "myapp"
</pre>
<p>See also <a href="qstring.html#split">split</a>().</p>
<h3 class="fn"><a name="section-2" /><a href="qstring.html">QString</a> QString.section (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>reg</i>, int&#160;<i>start</i>, int&#160;<i>end</i>&#160;=&#160;-1, <a href="qstring-sectionflags.html">SectionFlags</a>&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</h3><p>This is an overloaded member function, provided for convenience.</p>
<pre>
    QString data = "forename**middlename**surname**phone";
    QString str = data.section("**", 2, 2); // str == "surname"
</pre>
<pre>
    QString data = "forename**middlename**surname**phone";
    QString str = data.section("**", -3, -2); // str == "middlename**surname"
</pre>
<p>See also <a href="qstring.html#split">split</a>().</p>
<h3 class="fn"><a name="section-3" /><a href="qstring.html">QString</a> QString.section (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>asep</i>, int&#160;<i>astart</i>, int&#160;<i>aend</i>&#160;=&#160;-1, <a href="qstring-sectionflags.html">SectionFlags</a>&#160;<i>aflags</i>&#160;=&#160;QString.SectionDefault)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This string is treated as a sequence of fields separated by the regular expression, <i>reg</i>.</p>
<pre>
    QString line = "forename\tmiddlename  surname \t \t phone";
    QRegExp sep("\\s+");
    QString s = line.section(sep, 2, 2); // s == "surname"
</pre>
<pre>
    QString line = "forename\tmiddlename  surname \t \t phone";
    QRegExp sep("\\s+");
    QString s = line.section(sep, -3, -2); // s == "middlename  surname"
</pre>
<p><b>Warning:</b> Using this <a href="qregexp.html">QRegExp</a> version is much more expensive than the overloaded string and character versions.</p>
<p>See also <a href="qstring.html#split">split</a>() and <a href="qstring.html#simplified">simplified</a>().</p>
<h3 class="fn"><a name="setNum" /><a href="qstring.html">QString</a> QString.setNum (<i>self</i>, int&#160;<i>n</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Sets the string to the printed value of <i>n</i> in base <i>base</i> and returns a reference to the string.</p>
<p>The base is 10 by default and must be between 2 and 36.</p>
<pre>
    QString str;
    str.setNum(1234);       // str == "1234"
</pre>
<h3 class="fn"><a name="setNum-2" /><a href="qstring.html">QString</a> QString.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>
<h3 class="fn"><a name="setNum-3" /><a href="qstring.html">QString</a> QString.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>
<h3 class="fn"><a name="setNum-4" /><a href="qstring.html">QString</a> QString.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>
<h3 class="fn"><a name="simplified" /><a href="qstring.html">QString</a> QString.simplified (<i>self</i>)</h3><p>Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.</p>
<p>Whitespace means any character for which <a href="qchar.html#isSpace">QChar.isSpace</a>() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.</p>
<p>Example:</p>
<pre>
    QString str = "  lots\t of\nwhitespace\r\n ";
    str = str.simplified();
    // str == "lots of whitespace";
</pre>
<p>See also <a href="qstring.html#trimmed">trimmed</a>().</p>
<h3 class="fn"><a name="size" />int QString.size (<i>self</i>)</h3><p>Returns the number of characters in this string.</p>
<p>The last character in the string is at position size() - 1. In addition, <a href="qstring.html">QString</a> ensures that the character at position size() is always '\0', so that you can use the return value of <a href="qstring.html#data">data</a>() and <a href="qstring.html#constData">constData</a>() as arguments to functions that expect '\0'-terminated strings.</p>
<p>Example:</p>
<pre>
    QString str = "World";
    int n = str.size();         // n == 5
    str.data()[0];              // returns 'W'
    str.data()[4];              // returns 'd'
    str.data()[5];              // returns '\0'
</pre>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>() and <a href="qstring.html#resize">resize</a>().</p>
<h3 class="fn"><a name="split" /><a href="qstringlist.html">QStringList</a> QString.split (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>sep</i>, <a href="qstring.html#SplitBehavior-enum">SplitBehavior</a>&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Splits the string into substrings wherever <i>sep</i> occurs, and returns the list of those strings. If <i>sep</i> does not match anywhere in the string, split() returns a single-element list containing this string.</p>
<p>If <i>cs</i> is true, the string is only split only where characters are found that match <i>sep</i> exactly. If <i>cs</i> is false, the string is split, the string is split where characters are found that match <i>sep</i> case insensitively (e.g. "and" matches "AND").</p>
<p>If <i>behavior</i> is <a href="qstring.html#SplitBehavior-enum">QString.SkipEmptyParts</a>, empty entries don't appear in the result. By default, empty entries are kept.</p>
<p>Example:</p>
<pre>
    QString str = "a,,b,c";
    QStringList list1 = str.split(",");
    // list1: [ "a", "", "b", "c" ]

    QStringList list2 = str.split(",", QString.SkipEmptyParts);
    // list2: [ "a", "b", "c" ]
</pre>
<p>See also <a href="qstringlist.html#join">QStringList.join</a>() and <a href="qstring.html#section">section</a>().</p>
<h3 class="fn"><a name="split-2" /><a href="qstringlist.html">QStringList</a> QString.split (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>sep</i>, <a href="qstring.html#SplitBehavior-enum">SplitBehavior</a>&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="split-3" /><a href="qstringlist.html">QStringList</a> QString.split (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>sep</i>, <a href="qstring.html#SplitBehavior-enum">SplitBehavior</a>&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Splits the string into substrings wherever the regular expression <i>rx</i> matches, and returns the list of those strings. If <i>rx</i> does not match anywhere in the string, <a href="qstring.html#split">split</a>() returns a single-element list containing this string.</p>
<p>Here's an example where we extract the words in a sentence using one or more whitespace characters as the separator:</p>
<pre>
    QString str = "Some  text\n\twith  strange whitespace.";
    QStringList list = str.split(QRegExp("\\s+"));
    // list: [ "Some", "text", "with", "strange", "whitespace." ]
</pre>
<p>Here's a similar example, but this time we use any sequence of non-word characters as the separator:</p>
<pre>
    QString str = "This time, a normal English sentence.";
    QStringList list = str.split(QRegExp("\\W+"),
                                 QString.SkipEmptyParts);
    // list: [ "This", "time", "a", "normal", "English", "sentence" ]
</pre>
<p>Here's a third example where we use a zero-length assertion, <b>\b</b> (word boundary), to split the string into an alternating sequence of non-word and word tokens:</p>
<pre>
    QString str = "Now: this sentence fragment.";
    QStringList list = str.split(QRegExp("\\b"));
    // list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
</pre>
<p>See also <a href="qstringlist.html#join">QStringList.join</a>() and <a href="qstring.html#section">section</a>().</p>
<h3 class="fn"><a name="squeeze" />QString.squeeze (<i>self</i>)</h3><p>Releases any memory not required to store the character data.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qstring.html">QString</a>'s memory usage. In general, you will rarely ever need to call this function.</p>
<p>See also <a href="qstring.html#reserve">reserve</a>() and <a href="qstring.html#capacity">capacity</a>().</p>
<h3 class="fn"><a name="startsWith" />bool QString.startsWith (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns true if the string starts with <i>s</i>; otherwise returns false.</p>
<p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (the default), the search is case sensitive; otherwise the search is case insensitive.</p>
<pre>
    QString str = "Bananas";
    str.startsWith("Ban");     // returns true
    str.startsWith("Car");     // returns false
</pre>
<p>See also <a href="qstring.html#endsWith">endsWith</a>().</p>
<h3 class="fn"><a name="startsWith-2" />bool QString.startsWith (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="startsWith-3" />bool QString.startsWith (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="toAscii" /><a href="qbytearray.html">QByteArray</a> QString.toAscii (<i>self</i>)</h3><p>Returns an 8-bit ASCII representation of the string as a <a href="qbytearray.html">QByteArray</a>.</p>
<p>If a codec has been set using <a href="qtextcodec.html#setCodecForCStrings">QTextCodec.setCodecForCStrings</a>(), it is used to convert Unicode to 8-bit char; otherwise this function does the same as <a href="qstring.html#toLatin1">toLatin1</a>().</p>
<p>See also <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<h3 class="fn"><a name="toDouble" />(float, bool&#160;<i>ok</i>) QString.toDouble (<i>self</i>)</h3><p>Returns the string 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, <tt>*</tt><i>ok</i> is set to false; otherwise <tt>*</tt><i>ok</i> is set to true.</p>
<pre>
    QString str = "1234.56";
    double val = str.toDouble();   // val == 1234.56
</pre>
<p>This function tries to interpret the string according to the current locale. The current locale is determined from the system at application startup and can be changed by calling <a href="qlocale.html#setDefault">QLocale.setDefault</a>(). If the string cannot be interpreted according to the current locale, this function falls back on the "C" locale.</p>
<pre>
    bool ok;
    double d;

    QLocale.setDefault(QLocale.C);
    d = QString( "1234,56" ).toDouble(&amp;ok); // ok == false
    d = QString( "1234.56" ).toDouble(&amp;ok); // ok == true, d == 1234.56

    QLocale.setDefault(QLocale.German);
    d = QString( "1234,56" ).toDouble(&amp;ok); // ok == true, d == 1234.56
    d = QString( "1234.56" ).toDouble(&amp;ok); // ok == true, d == 1234.56
</pre>
<p>Due to the ambiguity between the decimal point and thousands group separator in various locales, this function does not handle thousands group separators. If you need to convert such numbers, see <a href="qlocale.html#toDouble">QLocale.toDouble</a>().</p>
<pre>
    bool ok;
    QLocale.setDefault(QLocale.C);
    double d = QString( "1,234,567.89" ).toDouble(&amp;ok); // ok == false
</pre>
<p><b>Warning:</b> If the string contains trailing whitespace this function will fail, and set <tt>*</tt><i>ok</i> to false if <i>ok</i> is not 0. Leading whitespace is ignored.</p>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qlocale.html#setDefault">QLocale.setDefault</a>(), <a href="qlocale.html#toDouble">QLocale.toDouble</a>(), and <a href="qstring.html#trimmed">trimmed</a>().</p>
<h3 class="fn"><a name="toFloat" />(float, bool&#160;<i>ok</i>) QString.toFloat (<i>self</i>)</h3><p>Returns the string 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>Example:</p>
<pre>
    QString str1 = "1234.56";
    str1.toFloat();             // returns 1234.56

    bool ok;
    QString str2 = "R2D2";
    str2.toFloat(&amp;ok);          // returns 0.0, sets ok to false
</pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toDouble">toDouble</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="toInt" />(int, bool&#160;<i>ok</i>) QString.toInt (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string 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. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString 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="qstring.html#number">number</a>(), <a href="qstring.html#toUInt">toUInt</a>(), and <a href="qstring.html#toDouble">toDouble</a>().</p>
<h3 class="fn"><a name="toLatin1" /><a href="qbytearray.html">QByteArray</a> QString.toLatin1 (<i>self</i>)</h3><p>Returns a Latin-1 representation of the string as a <a href="qbytearray.html">QByteArray</a>. The returned byte array is undefined if the string contains non-Latin1 characters.</p>
<p>See also <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<h3 class="fn"><a name="toLocal8Bit" /><a href="qbytearray.html">QByteArray</a> QString.toLocal8Bit (<i>self</i>)</h3><p>Returns the local 8-bit representation of the string as a <a href="qbytearray.html">QByteArray</a>. The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding.</p>
<p><a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>() is used to perform the conversion from Unicode.</p>
<p>See also <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>(), <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<h3 class="fn"><a name="toLong" />(long, bool&#160;<i>ok</i>) QString.toLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to a <tt>long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString 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>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toULong">toULong</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="toLongLong" />(long, bool&#160;<i>ok</i>) QString.toLongLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string 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. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString str = "FF";
    bool ok;
    long hex = str.toLongLong(&amp;ok, 16);      // hex == 255, ok == true
    long dec = str.toLongLong(&amp;ok, 10);      // dec == 0, ok == false
</pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toULongLong">toULongLong</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="toLower" /><a href="qstring.html">QString</a> QString.toLower (<i>self</i>)</h3><p>Returns a lowercase copy of the string.</p>
<pre>
    QString str = "TROlltECH";
    str = str.toLower();        // str == "trolltech"
</pre>
<p>See also <a href="qstring.html#toUpper">toUpper</a>().</p>
<h3 class="fn"><a name="toShort" />(int, bool&#160;<i>ok</i>) QString.toShort (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string 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. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString str = "FF";
    bool ok;
    short hex = str.toShort(&amp;ok, 16);   // hex == 255, ok == true
    short dec = str.toShort(&amp;ok, 10);   // dec == 0, ok == false
</pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toUShort">toUShort</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="toUInt" />(unsigned long, bool&#160;<i>ok</i>) QString.toUInt (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string 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. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString str = "FF";
    bool ok;
    uint hex = str.toUInt(&amp;ok, 16);     // hex == 255, ok == true
    uint dec = str.toUInt(&amp;ok, 10);     // dec == 0, ok == false
</pre>
<p>See also <a href="qstring.html#number">number</a>() and <a href="qstring.html#toInt">toInt</a>().</p>
<h3 class="fn"><a name="toULong" />(unsigned long, bool&#160;<i>ok</i>) QString.toULong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to an <tt>unsigned long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString str = "FF";
    bool ok;
    ulong hex = str.toULong(&amp;ok, 16);   // hex == 255, ok == true
    ulong dec = str.toULong(&amp;ok, 10);   // dec == 0, ok == false
</pre>
<p>See also <a href="qstring.html#number">number</a>().</p>
<h3 class="fn"><a name="toULongLong" />(unsigned long, bool&#160;<i>ok</i>) QString.toULongLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string 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. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString str = "FF";
    bool ok;
    unsigned long hex = str.toULongLong(&amp;ok, 16);    // hex == 255, ok == true
    unsigned long dec = str.toULongLong(&amp;ok, 10);    // dec == 0, ok == false
</pre>
<p>See also <a href="qstring.html#number">number</a>() and <a href="qstring.html#toLongLong">toLongLong</a>().</p>
<h3 class="fn"><a name="toUpper" /><a href="qstring.html">QString</a> QString.toUpper (<i>self</i>)</h3><p>Returns an uppercase copy of the string.</p>
<pre>
    QString str = "TeXt";
    str = str.toUpper();        // str == "TEXT"
</pre>
<p>See also <a href="qstring.html#toLower">toLower</a>().</p>
<h3 class="fn"><a name="toUShort" />(unsigned long, bool&#160;<i>ok</i>) QString.toUShort (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string 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. 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>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>
    QString str = "FF";
    bool ok;
    ushort hex = str.toUShort(&amp;ok, 16);     // hex == 255, ok == true
    ushort dec = str.toUShort(&amp;ok, 10);     // dec == 0, ok == false
</pre>
<p>See also <a href="qstring.html#number">number</a>() and <a href="qstring.html#toShort">toShort</a>().</p>
<h3 class="fn"><a name="toUtf8" /><a href="qbytearray.html">QByteArray</a> QString.toUtf8 (<i>self</i>)</h3><p>Returns a UTF-8 representation of the string as a <a href="qbytearray.html">QByteArray</a>.</p>
<p>See also <a href="qstring.html#fromUtf8">fromUtf8</a>(), <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<h3 class="fn"><a name="trimmed" /><a href="qstring.html">QString</a> QString.trimmed (<i>self</i>)</h3><p>Returns a string that has whitespace removed from the start and the end.</p>
<p>Whitespace means any character for which <a href="qchar.html#isSpace">QChar.isSpace</a>() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.</p>
<p>Example:</p>
<pre>
    QString str = "  lots\t of\nwhitespace\r\n ";
    str = str.trimmed();
    // str == "lots\t of\nwhitespace";
</pre>
<p>Unlike <a href="qstring.html#simplified">simplified</a>(), trimmed() leaves internal whitespace alone.</p>
<p>See also <a href="qstring.html#simplified">simplified</a>().</p>
<h3 class="fn"><a name="truncate" />QString.truncate (<i>self</i>, int&#160;<i>pos</i>)</h3><p>Truncates the string at index position <i>pos</i>.</p>
<p>If <i>pos</i> is beyond the end of the string, nothing happens.</p>
<p>Example:</p>
<pre>
    QString str = "Vladivostok";
    str.truncate(4);
    // str == "Vlad"
</pre>
<p>See also <a href="qstring.html#chop">chop</a>(), <a href="qstring.html#resize">resize</a>(), and <a href="qstring.html#left">left</a>().</p>
<h3 class="fn"><a name="__add__" /><a href="qstring.html">QString</a> QString.__add__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>ba</i>)</h3><h3 class="fn"><a name="__add__-2" /><a href="qstring.html">QString</a> QString.__add__ (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__add__-3" /><a href="qstring.html">QString</a> QString.__add__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__contains__" />int QString.__contains__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__eq__" />bool QString.__eq__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__eq__-2" />bool QString.__eq__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__eq__-3" />bool QString.__eq__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ge__" />bool QString.__ge__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ge__-2" />bool QString.__ge__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ge__-3" />bool QString.__ge__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__getitem__" /><a href="qstring.html">QString</a> QString.__getitem__ (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="__getitem__-2" /><a href="qstring.html">QString</a> QString.__getitem__ (<i>self</i>, slice&#160;<i>slice</i>)</h3><h3 class="fn"><a name="__gt__" />bool QString.__gt__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__gt__-2" />bool QString.__gt__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__gt__-3" />bool QString.__gt__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__hash__" />long QString.__hash__ (<i>self</i>)</h3><h3 class="fn"><a name="__iadd__" /><a href="qstring.html">QString</a> QString.__iadd__ (<i>self</i>, <a href="qchar.html">QChar</a>&#160;<i>c</i>)</h3><h3 class="fn"><a name="__iadd__-2" /><a href="qstring.html">QString</a> QString.__iadd__ (<i>self</i>, <a href="qchar.html#SpecialCharacter-enum">QChar.SpecialCharacter</a>&#160;<i>c</i>)</h3><h3 class="fn"><a name="__iadd__-3" /><a href="qstring.html">QString</a> QString.__iadd__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__iadd__-4" /><a href="qstring.html">QString</a> QString.__iadd__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__iadd__-5" /><a href="qstring.html">QString</a> QString.__iadd__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__imul__" /><a href="qstring.html">QString</a> QString.__imul__ (<i>self</i>, int&#160;<i>m</i>)</h3><h3 class="fn"><a name="__le__" />bool QString.__le__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__le__-2" />bool QString.__le__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__le__-3" />bool QString.__le__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__len__" />int QString.__len__ (<i>self</i>)</h3><h3 class="fn"><a name="__lt__" />bool QString.__lt__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__lt__-2" />bool QString.__lt__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__lt__-3" />bool QString.__lt__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__mul__" /><a href="qstring.html">QString</a> QString.__mul__ (<i>self</i>, int&#160;<i>m</i>)</h3><h3 class="fn"><a name="__ne__" />bool QString.__ne__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ne__-2" />bool QString.__ne__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ne__-3" />bool QString.__ne__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__str__" />object QString.__str__ (<i>self</i>)</h3><h3 class="fn"><a name="__unicode__" />object QString.__unicode__ (<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>