aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp
blob: 7108262059b77da2d94bd6f9ca1fcd1c946d791c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! [0]
static uchar bindata[] = { 231, 1, 44, ... };
QByteArray	a;
a.setRawData(bindata, sizeof(bindata));	// a points to bindata
QDataStream s(a, IO_ReadOnly);		// open on a's data
s >> <something>;				// read raw bindata
s.close();
a.resetRawData(bindata, sizeof(bindata)); // finished
//! [0]


//! [1]
static uchar bindata[] = { 231, 1, 44, ... };
QByteArray	a, b;
a.setRawData(bindata, sizeof(bindata));	// a points to bindata
a.resize(8);				// will crash
b = a;					// will crash
a[2] = 123;					// might crash
  // forget to resetRawData - will crash
//! [1]