1QSqlPropertyMap(3qt) QSqlPropertyMap(3qt)
2
3
4
6 QSqlPropertyMap - Used to map widgets to SQL fields
7
9 #include <qsqlpropertymap.h>
10
11 Public Members
12 QSqlPropertyMap ()
13 virtual ~QSqlPropertyMap ()
14 QVariant property ( QWidget * widget )
15 virtual void setProperty ( QWidget * widget, const QVariant & value )
16 void insert ( const QString & classname, const QString & property )
17 void remove ( const QString & classname )
18
19 Static Public Members
20 QSqlPropertyMap * defaultMap ()
21 void installDefaultMap ( QSqlPropertyMap * map )
22
24 The QSqlPropertyMap class is used to map widgets to SQL fields.
25
26 The SQL module uses Qt object properties to insert and extract values
27 from editor widgets.
28
29 This class is used to map editors to SQL fields. This works by
30 associating SQL editor class names to the properties used to insert and
31 extract values to/from the editor.
32
33 For example, a QLineEdit can be used to edit text strings and other
34 data types in QDataTables or QSqlForms. Several properties are defined
35 in QLineEdit, but only the text property is used to insert and extract
36 text from a QLineEdit. Both QDataTable and QSqlForm use the global
37 QSqlPropertyMap for inserting and extracting values to and from an
38 editor widget. The global property map defines several common widgets
39 and properties that are suitable for many applications. You can add and
40 remove widget properties to suit your specific needs.
41
42 If you want to use custom editors with your QDataTable or QSqlForm, you
43 must install your own QSqlPropertyMap for that table or form. Example:
44
45 QSqlPropertyMap *myMap = new QSqlPropertyMap();
46 QSqlForm *myForm = new QSqlForm( this );
47 MyEditor myEditor( this );
48 // Set the QSqlForm's record buffer to the update buffer of
49 // a pre-existing QSqlCursor called 'cur'.
50 myForm->setRecord( cur->primeUpdate() );
51 // Install the customized map
52 myMap->insert( "MyEditor", "content" );
53 myForm->installPropertyMap( myMap ); // myForm now owns myMap
54 ...
55 // Insert a field into the form that uses a myEditor to edit the
56 // field 'somefield'
57 myForm->insert( &myEditor, "somefield" );
58 // Update myEditor with the value from the mapped database field
59 myForm->readFields();
60 ...
61 // Let the user edit the form
62 ...
63 // Update the database fields with the values in the form
64 myForm->writeFields();
65 ...
66
67 You can also replace the global QSqlPropertyMap that is used by
68 default. (Bear in mind that QSqlPropertyMap takes ownership of the new
69 default map.)
70
71 QSqlPropertyMap *myMap = new QSqlPropertyMap;
72 myMap->insert( "MyEditor", "content" );
73 QSqlPropertyMap::installDefaultMap( myMap );
74 ...
75
76 See also QDataTable, QSqlForm, QSqlEditorFactory, and Database Classes.
77
80 Constructs a QSqlPropertyMap.
81
82 The default property mappings used by Qt widgets are: <center>.nf
83
84 </center>
85
87 Destroys the QSqlPropertyMap.
88
89 Note that if the QSqlPropertyMap is installed with installPropertyMap()
90 the object it was installed into, e.g. the QSqlForm, takes ownership
91 and will delete the QSqlPropertyMap when necessary.
92
94 Returns the application global QSqlPropertyMap.
95
97 property )
98 Insert a new classname/property pair, which is used for custom SQL
99 field editors. There must be a Q_PROPERTY clause in the classname class
100 declaration for the property.
101
102 Example: sql/overview/custom1/main.cpp.
103
105 Replaces the global default property map with map. All QDataTable and
106 QSqlForm instantiations will use this new map for inserting and
107 extracting values to and from editors. QSqlPropertyMap takes ownership
108 of \a map, and destroys it when it is no longer needed.
109
111 Returns the mapped property of widget as a QVariant.
112
114 Removes classname from the map.
115
117 [virtual]
118 Sets the property of widget to value.
119
120
122 http://doc.trolltech.com/qsqlpropertymap.html
123 http://www.trolltech.com/faq/tech.html
124
126 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
127 license file included in the distribution for a complete license
128 statement.
129
131 Generated automatically from the source code.
132
134 If you find a bug in Qt, please report it as described in
135 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
136 help you. Thank you.
137
138 The definitive Qt documentation is provided in HTML format; it is
139 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
140 web browser. This man page is provided as a convenience for those users
141 who prefer man pages, although this format is not officially supported
142 by Trolltech.
143
144 If you find errors in this manual page, please report them to qt-
145 bugs@trolltech.com. Please include the name of the manual page
146 (qsqlpropertymap.3qt) and the Qt version (3.3.8).
147
148
149
150Trolltech AS 2 February 2007 QSqlPropertyMap(3qt)