aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp
blob: 664a6909b46b9621c443bf8a283d4f8f2e18f678 (plain)
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
//! [0]
QString str;
Q3TextStream ts( &str, IO_WriteOnly );
ts << "pi = " << 3.14; // str == "pi = 3.14"
//! [0]


//! [1]
QString str = "pi = 3.14";
Q3TextStream ts( &str, IO_WriteOnly );
ts <<  "2+2 = " << 2+2; // str == "2+2 = 414"
//! [1]


//! [2]
QByteArray array;
Q3TextStream ts( array, IO_WriteOnly );
ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
//! [2]


//! [3]
QByteArray array;
QBuffer buf( array );
buf.open( IO_WriteOnly );
Q3TextStream ts( &buf );
ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
buf.close();
//! [3]