source: trunk/doc/src/snippets/code/doc_src_q3intdict.qdoc@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 1.2 KB
Line 
1//! [0]
2Q3IntDict<QLineEdit> fields; // long int keys, QLineEdit* values
3for ( int i = 0; i < 3; i++ )
4 fields.insert( i, new QLineEdit( this ) );
5
6fields[0]->setText( "Homer" );
7fields[1]->setText( "Simpson" );
8fields[2]->setText( "45" );
9
10Q3IntDictIterator<QLineEdit> it( fields );
11for ( ; it.current(); ++it )
12 cout << it.currentKey() << ": " << it.current()->text() << endl;
13
14for ( int i = 0; i < 3; i++ )
15 cout << fields[i]->text() << " "; // Prints "Homer Simpson 45"
16cout << endl;
17
18fields.remove( 1 ); // Does not delete the line edit
19for ( int i = 0; i < 3; i++ )
20 if ( fields[i] )
21 cout << fields[i]->text() << " "; // Prints "Homer 45"
22//! [0]
23
24
25//! [1]
26Q3IntDict<char> dict;
27// ...
28if ( dict.find(key) )
29 dict.remove( key );
30dict.insert( key, item );
31//! [1]
32
33
34//! [2]
35Q3IntDict<QLineEdit> fields;
36for ( int i = 0; i < 3; i++ )
37 fields.insert( i, new QLineEdit( this ) );
38
39fields[0]->setText( "Homer" );
40fields[1]->setText( "Simpson" );
41fields[2]->setText( "45" );
42
43Q3IntDictIterator<QLineEdit> it( fields );
44for ( ; it.current(); ++it )
45 cout << it.currentKey() << ": " << it.current()->text() << endl;
46
47// Output (random order):
48// 0: Homer
49// 1: Simpson
50// 2: 45
51//! [2]
Note: See TracBrowser for help on using the repository browser.