summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqsqlpropertymap.3qt
blob: 9fe2ccc43d64c07dc13b6f784f762569f92ab2da (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
'\" t
.TH TQSqlPropertyMap 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQSqlPropertyMap \- Used to map widgets to SQL fields
.SH SYNOPSIS
\fC#include <tqsqlpropertymap.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQSqlPropertyMap\fR ()"
.br
.ti -1c
.BI "virtual \fB~TQSqlPropertyMap\fR ()"
.br
.ti -1c
.BI "TQVariant \fBproperty\fR ( TQWidget * widget )"
.br
.ti -1c
.BI "virtual void \fBsetProperty\fR ( TQWidget * widget, const TQVariant & value )"
.br
.ti -1c
.BI "void \fBinsert\fR ( const TQString & classname, const TQString & property )"
.br
.ti -1c
.BI "void \fBremove\fR ( const TQString & classname )"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "TQSqlPropertyMap * \fBdefaultMap\fR ()"
.br
.ti -1c
.BI "void \fBinstallDefaultMap\fR ( TQSqlPropertyMap * map )"
.br
.in -1c
.SH DESCRIPTION
The TQSqlPropertyMap class is used to map widgets to SQL fields.
.PP
The SQL module uses TQt object properties to insert and extract values from editor widgets.
.PP
This class is used to map editors to SQL fields. This works by associating SQL editor class names to the properties used to insert and extract values to/from the editor.
.PP
For example, a TQLineEdit can be used to edit text strings and other data types in TQDataTables or TQSqlForms. Several properties are defined in TQLineEdit, but only the \fItext\fR property is used to insert and extract text from a TQLineEdit. Both TQDataTable and TQSqlForm use the global TQSqlPropertyMap for inserting and extracting values to and from an editor widget. The global property map defines several common widgets and properties that are suitable for many applications. You can add and remove widget properties to suit your specific needs.
.PP
If you want to use custom editors with your TQDataTable or TQSqlForm, you must install your own TQSqlPropertyMap for that table or form. Example:
.PP
.nf
.br
    TQSqlPropertyMap *myMap  = new TQSqlPropertyMap();
.br
    TQSqlForm        *myForm = new TQSqlForm( this );
.br
    MyEditor myEditor( this );
.br
.br
    // Set the TQSqlForm's record buffer to the update buffer of
.br
    // a pre-existing TQSqlCursor called 'cur'.
.br
    myForm->setRecord( cur->primeUpdate() );
.br
.br
    // Install the customized map
.br
    myMap->insert( "MyEditor", "content" );
.br
    myForm->installPropertyMap( myMap ); // myForm now owns myMap
.br
    ...
.br
    // Insert a field into the form that uses a myEditor to edit the
.br
    // field 'somefield'
.br
    myForm->insert( &myEditor, "somefield" );
.br
.br
    // Update myEditor with the value from the mapped database field
.br
    myForm->readFields();
.br
    ...
.br
    // Let the user edit the form
.br
    ...
.br
    // Update the database fields with the values in the form
.br
    myForm->writeFields();
.br
    ...
.br
.fi
.PP
You can also replace the global TQSqlPropertyMap that is used by default. (Bear in mind that TQSqlPropertyMap takes ownership of the new default map.)
.PP
.nf
.br
    TQSqlPropertyMap *myMap = new TQSqlPropertyMap;
.br
.br
    myMap->insert( "MyEditor", "content" );
.br
    TQSqlPropertyMap::installDefaultMap( myMap );
.br
    ...
.br
.fi
.PP
See also TQDataTable, TQSqlForm, TQSqlEditorFactory, and Database Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQSqlPropertyMap::TQSqlPropertyMap ()"
Constructs a TQSqlPropertyMap.
.PP
The default property mappings used by TQt widgets are: <center>.nf
.TS
l - l. Widgets Property TQCheckBox, TQRadioButton checked TQComboBox, TQListBox currentItem TQDateEdit date TQDateTimeEdit dateTime TQTextBrowser source TQButton, TQDial, TQLabel, TQLineEdit, TQMultiLineEdit, TQPushButton, TQTextEdit, text TQTimeEdit time TQLCDNumber, TQScrollBar TQSlider, TQSpinBox
.TE
.fi
</center>
.SH "TQSqlPropertyMap::~TQSqlPropertyMap ()\fC [virtual]\fR"
Destroys the TQSqlPropertyMap.
.PP
Note that if the TQSqlPropertyMap is installed with installPropertyMap() the object it was installed into, e.g. the TQSqlForm, takes ownership and will delete the TQSqlPropertyMap when necessary.
.SH "TQSqlPropertyMap * TQSqlPropertyMap::defaultMap ()\fC [static]\fR"
Returns the application global TQSqlPropertyMap.
.SH "void TQSqlPropertyMap::insert ( const TQString & classname, const TQString & property )"
Insert a new classname/property pair, which is used for custom SQL field editors. There \fImust\fR be a \fCTQ_PROPERTY\fR clause in the \fIclassname\fR class declaration for the \fIproperty\fR.
.PP
Example: sql/overview/custom1/main.cpp.
.SH "void TQSqlPropertyMap::installDefaultMap ( TQSqlPropertyMap * map )\fC [static]\fR"
Replaces the global default property map with \fImap\fR. All TQDataTable and TQSqlForm instantiations will use this new map for inserting and extracting values to and from editors. \fITQSqlPropertyMap takes ownership of &#92;a map, and destroys it when it is no longer needed.\fR
.SH "TQVariant TQSqlPropertyMap::property ( TQWidget * widget )"
Returns the mapped property of \fIwidget\fR as a TQVariant.
.SH "void TQSqlPropertyMap::remove ( const TQString & classname )"
Removes \fIclassname\fR from the map.
.SH "void TQSqlPropertyMap::setProperty ( TQWidget * widget, const TQVariant & value )\fC [virtual]\fR"
Sets the property of \fIwidget\fR to \fIvalue\fR.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqsqlpropertymap.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqsqlpropertymap.3qt) and the Qt
version (3.3.8).