1 | //! [0]
|
---|
2 | Q3AsciiDict<QLineEdit> fields; // char* keys, QLineEdit* values
|
---|
3 | fields.insert( "forename", new QLineEdit( this ) );
|
---|
4 | fields.insert( "surname", new QLineEdit( this ) );
|
---|
5 |
|
---|
6 | fields["forename"]->setText( "Homer" );
|
---|
7 | fields["surname"]->setText( "Simpson" );
|
---|
8 |
|
---|
9 | Q3AsciiDictIterator<QLineEdit> it( fields ); // See Q3AsciiDictIterator
|
---|
10 | for( ; it.current(); ++it )
|
---|
11 | cout << it.currentKey() << ": " << it.current()->text() << endl;
|
---|
12 | cout << endl;
|
---|
13 |
|
---|
14 | if ( fields["forename"] && fields["surname"] )
|
---|
15 | cout << fields["forename"]->text() << " "
|
---|
16 | << fields["surname"]->text() << endl; // Prints "Homer Simpson"
|
---|
17 |
|
---|
18 | fields.remove( "forename" ); // Does not delete the line edit
|
---|
19 | if ( ! fields["forename"] )
|
---|
20 | cout << "forename is not in the dictionary" << endl;
|
---|
21 | //! [0]
|
---|
22 |
|
---|
23 |
|
---|
24 | //! [1]
|
---|
25 | Q3AsciiDict<char> dict;
|
---|
26 | ...
|
---|
27 | if ( dict.find(key) )
|
---|
28 | dict.remove( key );
|
---|
29 | dict.insert( key, item );
|
---|
30 | //! [1]
|
---|
31 |
|
---|
32 |
|
---|
33 | //! [2]
|
---|
34 | Q3AsciiDict<QLineEdit> fields;
|
---|
35 | fields.insert( "forename", new QLineEdit( this ) );
|
---|
36 | fields.insert( "surname", new QLineEdit( this ) );
|
---|
37 | fields.insert( "age", new QLineEdit( this ) );
|
---|
38 |
|
---|
39 | fields["forename"]->setText( "Homer" );
|
---|
40 | fields["surname"]->setText( "Simpson" );
|
---|
41 | fields["age"]->setText( "45" );
|
---|
42 |
|
---|
43 | Q3AsciiDictIterator<QLineEdit> it( fields );
|
---|
44 | for( ; it.current(); ++it )
|
---|
45 | cout << it.currentKey() << ": " << it.current()->text() << endl;
|
---|
46 | cout << endl;
|
---|
47 |
|
---|
48 | // Output (random order):
|
---|
49 | // age: 45
|
---|
50 | // surname: Simpson
|
---|
51 | // forename: Homer
|
---|
52 | //! [2]
|
---|