[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qsqlpropertymap.cpp:53 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QSqlPropertyMap Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSqlPropertyMap Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QSqlPropertyMap class is used to map widgets to SQL fields.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qsqlpropertymap-h.html">qsqlpropertymap.h</a>></tt>
|
---|
| 37 | <p><a href="qsqlpropertymap-members.html">List of all member functions.</a>
|
---|
| 38 | <h2>Public Members</h2>
|
---|
| 39 | <ul>
|
---|
| 40 | <li class=fn><a href="#QSqlPropertyMap"><b>QSqlPropertyMap</b></a> ()</li>
|
---|
| 41 | <li class=fn>virtual <a href="#~QSqlPropertyMap"><b>~QSqlPropertyMap</b></a> ()</li>
|
---|
| 42 | <li class=fn>QVariant <a href="#property"><b>property</b></a> ( QWidget * widget )</li>
|
---|
| 43 | <li class=fn>virtual void <a href="#setProperty"><b>setProperty</b></a> ( QWidget * widget, const QVariant & value )</li>
|
---|
| 44 | <li class=fn>void <a href="#insert"><b>insert</b></a> ( const QString & classname, const QString & property )</li>
|
---|
| 45 | <li class=fn>void <a href="#remove"><b>remove</b></a> ( const QString & classname )</li>
|
---|
| 46 | </ul>
|
---|
| 47 | <h2>Static Public Members</h2>
|
---|
| 48 | <ul>
|
---|
| 49 | <li class=fn>QSqlPropertyMap * <a href="#defaultMap"><b>defaultMap</b></a> ()</li>
|
---|
| 50 | <li class=fn>void <a href="#installDefaultMap"><b>installDefaultMap</b></a> ( QSqlPropertyMap * map )</li>
|
---|
| 51 | </ul>
|
---|
| 52 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | The QSqlPropertyMap class is used to map widgets to SQL fields.
|
---|
| 56 | <p>
|
---|
| 57 |
|
---|
| 58 | <p> The SQL module uses Qt <a href="properties.html">object
|
---|
| 59 | properties</a> to insert and extract values from editor
|
---|
| 60 | widgets.
|
---|
| 61 | <p> This class is used to map editors to SQL fields. This works by
|
---|
| 62 | associating SQL editor class names to the properties used to
|
---|
| 63 | insert and extract values to/from the editor.
|
---|
| 64 | <p> For example, a <a href="qlineedit.html">QLineEdit</a> can be used to edit text strings and
|
---|
| 65 | other data types in QDataTables or QSqlForms. Several properties
|
---|
| 66 | are defined in QLineEdit, but only the <em>text</em> property is used to
|
---|
| 67 | insert and extract text from a QLineEdit. Both <a href="qdatatable.html">QDataTable</a> and
|
---|
| 68 | <a href="qsqlform.html">QSqlForm</a> use the global QSqlPropertyMap for inserting and
|
---|
| 69 | extracting values to and from an editor widget. The global
|
---|
| 70 | property map defines several common widgets and properties that
|
---|
| 71 | are suitable for many applications. You can add and remove widget
|
---|
| 72 | properties to suit your specific needs.
|
---|
| 73 | <p> If you want to use custom editors with your QDataTable or
|
---|
| 74 | QSqlForm, you must install your own QSqlPropertyMap for that table
|
---|
| 75 | or form. Example:
|
---|
| 76 | <p> <pre>
|
---|
| 77 | QSqlPropertyMap *myMap = new QSqlPropertyMap();
|
---|
| 78 | <a href="qsqlform.html">QSqlForm</a> *myForm = new <a href="qsqlform.html">QSqlForm</a>( this );
|
---|
| 79 | MyEditor myEditor( this );
|
---|
| 80 |
|
---|
| 81 | // Set the QSqlForm's record buffer to the update buffer of
|
---|
| 82 | // a pre-existing QSqlCursor called 'cur'.
|
---|
| 83 | myForm-><a href="qsqlform.html#setRecord">setRecord</a>( cur->primeUpdate() );
|
---|
| 84 |
|
---|
| 85 | // Install the customized map
|
---|
| 86 | myMap-><a href="#insert">insert</a>( "MyEditor", "content" );
|
---|
| 87 | myForm-><a href="qsqlform.html#installPropertyMap">installPropertyMap</a>( myMap ); // myForm now owns myMap
|
---|
| 88 | ...
|
---|
| 89 | // Insert a field into the form that uses a myEditor to edit the
|
---|
| 90 | // field 'somefield'
|
---|
| 91 | myForm-><a href="qsqlform.html#insert">insert</a>( &myEditor, "somefield" );
|
---|
| 92 |
|
---|
| 93 | // Update myEditor with the value from the mapped database field
|
---|
| 94 | myForm-><a href="qsqlform.html#readFields">readFields</a>();
|
---|
| 95 | ...
|
---|
| 96 | // Let the user edit the form
|
---|
| 97 | ...
|
---|
| 98 | // Update the database fields with the values in the form
|
---|
| 99 | myForm-><a href="qsqlform.html#writeFields">writeFields</a>();
|
---|
| 100 | ...
|
---|
| 101 | </pre>
|
---|
| 102 |
|
---|
| 103 | <p> You can also replace the global QSqlPropertyMap that is used by
|
---|
| 104 | default. (Bear in mind that QSqlPropertyMap takes ownership of the
|
---|
| 105 | new default map.)
|
---|
| 106 | <p> <pre>
|
---|
| 107 | QSqlPropertyMap *myMap = new QSqlPropertyMap;
|
---|
| 108 |
|
---|
| 109 | myMap-><a href="#insert">insert</a>( "MyEditor", "content" );
|
---|
| 110 | QSqlPropertyMap::<a href="#installDefaultMap">installDefaultMap</a>( myMap );
|
---|
| 111 | ...
|
---|
| 112 | </pre>
|
---|
| 113 |
|
---|
| 114 | <p> <p>See also <a href="qdatatable.html">QDataTable</a>, <a href="qsqlform.html">QSqlForm</a>, <a href="qsqleditorfactory.html">QSqlEditorFactory</a>, and <a href="database.html">Database Classes</a>.
|
---|
| 115 |
|
---|
| 116 | <hr><h2>Member Function Documentation</h2>
|
---|
| 117 | <h3 class=fn><a name="QSqlPropertyMap"></a>QSqlPropertyMap::QSqlPropertyMap ()
|
---|
| 118 | </h3>
|
---|
| 119 | <p> Constructs a QSqlPropertyMap.
|
---|
| 120 | <p> The default property mappings used by Qt widgets are:
|
---|
| 121 | <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
| 122 | <tr bgcolor="#a2c511"> <th valign="top">Widgets <th valign="top">Property
|
---|
| 123 | <tr bgcolor="#f0f0f0"> <td valign="top"><a href="qcheckbox.html">QCheckBox</a>,
|
---|
| 124 | <a href="qradiobutton.html">QRadioButton</a>
|
---|
| 125 | <td valign="top">checked
|
---|
| 126 | <tr bgcolor="#d0d0d0"> <td valign="top"><a href="qcombobox.html">QComboBox</a>,
|
---|
| 127 | <a href="qlistbox.html">QListBox</a>
|
---|
| 128 | <td valign="top">currentItem
|
---|
| 129 | <tr bgcolor="#f0f0f0"> <td valign="top"><a href="qdateedit.html">QDateEdit</a>
|
---|
| 130 | <td valign="top">date
|
---|
| 131 | <tr bgcolor="#d0d0d0"> <td valign="top"><a href="qdatetimeedit.html">QDateTimeEdit</a>
|
---|
| 132 | <td valign="top">dateTime
|
---|
| 133 | <tr bgcolor="#f0f0f0"> <td valign="top"><a href="qtextbrowser.html">QTextBrowser</a>
|
---|
| 134 | <td valign="top">source
|
---|
| 135 | <tr bgcolor="#d0d0d0"> <td valign="top"><a href="qbutton.html">QButton</a>,
|
---|
| 136 | <a href="qdial.html">QDial</a>,
|
---|
| 137 | <a href="qlabel.html">QLabel</a>,
|
---|
| 138 | <a href="qlineedit.html">QLineEdit</a>,
|
---|
| 139 | <a href="qmultilineedit.html">QMultiLineEdit</a>,
|
---|
| 140 | <a href="qpushbutton.html">QPushButton</a>,
|
---|
| 141 | <a href="qtextedit.html">QTextEdit</a>,
|
---|
| 142 | <td valign="top">text
|
---|
| 143 | <tr bgcolor="#f0f0f0"> <td valign="top"><a href="qtimeedit.html">QTimeEdit</a>
|
---|
| 144 | <td valign="top">time
|
---|
| 145 | <tr bgcolor="#d0d0d0"> <td valign="top"><a href="qlcdnumber.html">QLCDNumber</a>,
|
---|
| 146 | <a href="qscrollbar.html">QScrollBar</a>
|
---|
| 147 | <a href="qslider.html">QSlider</a>,
|
---|
| 148 | <a href="qspinbox.html">QSpinBox</a>
|
---|
| 149 | <td valign="top">value
|
---|
| 150 | </table></center>
|
---|
| 151 |
|
---|
| 152 | <h3 class=fn><a name="~QSqlPropertyMap"></a>QSqlPropertyMap::~QSqlPropertyMap ()<tt> [virtual]</tt>
|
---|
| 153 | </h3>
|
---|
| 154 | Destroys the QSqlPropertyMap.
|
---|
| 155 | <p> Note that if the QSqlPropertyMap is installed with
|
---|
| 156 | installPropertyMap() the object it was installed into, e.g. the
|
---|
| 157 | <a href="qsqlform.html">QSqlForm</a>, takes ownership and will delete the QSqlPropertyMap when
|
---|
| 158 | necessary.
|
---|
| 159 |
|
---|
| 160 | <h3 class=fn><a href="qsqlpropertymap.html">QSqlPropertyMap</a> * <a name="defaultMap"></a>QSqlPropertyMap::defaultMap ()<tt> [static]</tt>
|
---|
| 161 | </h3>
|
---|
| 162 | Returns the application global QSqlPropertyMap.
|
---|
| 163 |
|
---|
| 164 | <h3 class=fn>void <a name="insert"></a>QSqlPropertyMap::insert ( const <a href="qstring.html">QString</a> & classname, const <a href="qstring.html">QString</a> & property )
|
---|
| 165 | </h3>
|
---|
| 166 | Insert a new classname/property pair, which is used for custom SQL
|
---|
| 167 | field editors. There <em>must</em> be a <tt>Q_PROPERTY</tt> clause in the <em>classname</em> class declaration for the <em>property</em>.
|
---|
| 168 |
|
---|
| 169 | <p>Example: <a href="sql.html#x2239">sql/overview/custom1/main.cpp</a>.
|
---|
| 170 | <h3 class=fn>void <a name="installDefaultMap"></a>QSqlPropertyMap::installDefaultMap ( <a href="qsqlpropertymap.html">QSqlPropertyMap</a> * map )<tt> [static]</tt>
|
---|
| 171 | </h3>
|
---|
| 172 | Replaces the global default property map with <em>map</em>. All
|
---|
| 173 | <a href="qdatatable.html">QDataTable</a> and <a href="qsqlform.html">QSqlForm</a> instantiations will use this new map for
|
---|
| 174 | inserting and extracting values to and from editors.
|
---|
| 175 | <em>QSqlPropertyMap takes ownership of \a map, and destroys it when it is no longer needed.</em>
|
---|
| 176 |
|
---|
| 177 | <h3 class=fn><a href="qvariant.html">QVariant</a> <a name="property"></a>QSqlPropertyMap::property ( <a href="qwidget.html">QWidget</a> * widget )
|
---|
| 178 | </h3>
|
---|
| 179 | Returns the mapped property of <em>widget</em> as a <a href="qvariant.html">QVariant</a>.
|
---|
| 180 |
|
---|
| 181 | <h3 class=fn>void <a name="remove"></a>QSqlPropertyMap::remove ( const <a href="qstring.html">QString</a> & classname )
|
---|
| 182 | </h3>
|
---|
| 183 | Removes <em>classname</em> from the map.
|
---|
| 184 |
|
---|
| 185 | <h3 class=fn>void <a name="setProperty"></a>QSqlPropertyMap::setProperty ( <a href="qwidget.html">QWidget</a> * widget, const <a href="qvariant.html">QVariant</a> & value )<tt> [virtual]</tt>
|
---|
| 186 | </h3>
|
---|
| 187 | Sets the property of <em>widget</em> to <em>value</em>.
|
---|
| 188 |
|
---|
| 189 | <!-- eof -->
|
---|
| 190 | <hr><p>
|
---|
| 191 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 192 | Copyright © 1995-2007
|
---|
| 193 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 194 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 195 | <td>Copyright © 2007
|
---|
| 196 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 197 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 198 | </table></div></address></body>
|
---|
| 199 | </html>
|
---|