source: trunk/doc/html/sql-overview-form1-main-cpp.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 5.2 KB
Line 
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/doc/sql.doc:55 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>sql/overview/form1/main.cpp Example File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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>sql/overview/form1/main.cpp Example File</h1>
33
34
35<pre>/****************************************************************************
36** $Id: sql-overview-form1-main-cpp.html 2051 2007-02-21 10:04:20Z chehrlic $
37**
38** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
39**
40** This file is part of an example program for Qt. This example
41** program may be used, distributed and modified without limitation.
42**
43*****************************************************************************/
44
45#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
46#include &lt;<a href="qdialog-h.html">qdialog.h</a>&gt;
47#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
48#include &lt;<a href="qlayout-h.html">qlayout.h</a>&gt;
49#include &lt;<a href="qlineedit-h.html">qlineedit.h</a>&gt;
50#include &lt;<a href="qsqldatabase-h.html">qsqldatabase.h</a>&gt;
51#include &lt;<a href="qsqlcursor-h.html">qsqlcursor.h</a>&gt;
52#include &lt;<a href="qsqlform-h.html">qsqlform.h</a>&gt;
53#include "../connection.h"
54
55class FormDialog : public <a href="qdialog.html">QDialog</a>
56{
57 public:
58 FormDialog();
59};
60
61
62<a name="f15"></a>FormDialog::FormDialog()
63{
64 <a href="qlabel.html">QLabel</a> *forenameLabel = new <a href="qlabel.html">QLabel</a>( "Forename:", this );
65 <a href="qlabel.html">QLabel</a> *forenameDisplay = new <a href="qlabel.html">QLabel</a>( this );
66 <a href="qlabel.html">QLabel</a> *surnameLabel = new <a href="qlabel.html">QLabel</a>( "Surname:", this );
67 <a href="qlabel.html">QLabel</a> *surnameDisplay = new <a href="qlabel.html">QLabel</a>( this );
68 <a href="qlabel.html">QLabel</a> *salaryLabel = new <a href="qlabel.html">QLabel</a>( "Salary:", this );
69 <a href="qlineedit.html">QLineEdit</a> *salaryEdit = new <a href="qlineedit.html">QLineEdit</a>( this );
70
71 <a href="qgridlayout.html">QGridLayout</a> *grid = new <a href="qgridlayout.html">QGridLayout</a>( this );
72 grid-&gt;<a href="qgridlayout.html#addWidget">addWidget</a>( forenameLabel, 0, 0 );
73 grid-&gt;<a href="qgridlayout.html#addWidget">addWidget</a>( forenameDisplay, 0, 1 );
74 grid-&gt;<a href="qgridlayout.html#addWidget">addWidget</a>( surnameLabel, 1, 0 );
75 grid-&gt;<a href="qgridlayout.html#addWidget">addWidget</a>( surnameDisplay, 1, 1 );
76 grid-&gt;<a href="qgridlayout.html#addWidget">addWidget</a>( salaryLabel, 2, 0 );
77 grid-&gt;<a href="qgridlayout.html#addWidget">addWidget</a>( salaryEdit, 2, 1 );
78 grid-&gt;<a href="qlayout.html#activate">activate</a>();
79
80 <a href="qsqlcursor.html">QSqlCursor</a> staffCursor( "staff" );
81 staffCursor.<a href="qsqlcursor.html#select">select</a>();
82 staffCursor.<a href="qsqlquery.html#next">next</a>();
83
84 <a href="qsqlform.html">QSqlForm</a> sqlForm( this );
85 sqlForm.<a href="qsqlform.html#setRecord">setRecord</a>( staffCursor.<a href="qsqlcursor.html#primeUpdate">primeUpdate</a>() );
86 sqlForm.<a href="qsqlform.html#insert">insert</a>( forenameDisplay, "forename" );
87 sqlForm.<a href="qsqlform.html#insert">insert</a>( surnameDisplay, "surname" );
88 sqlForm.<a href="qsqlform.html#insert">insert</a>( salaryEdit, "salary" );
89 sqlForm.<a href="qsqlform.html#readFields">readFields</a>();
90}
91
92
93int main( int argc, char *argv[] )
94{
95 <a href="qapplication.html">QApplication</a> app( argc, argv );
96
97 if ( ! createConnections() ) return 1;
98
99 FormDialog *formDialog = new FormDialog();
100 formDialog-&gt;<a href="qdialog.html#show">show</a>();
101 app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( formDialog );
102
103 return app.<a href="qapplication.html#exec">exec</a>();
104}
105</pre><!-- eof -->
106<p><address><hr><div align=center>
107<table width=100% cellspacing=0 border=0><tr>
108<td>Copyright &copy; 2007
109<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
110<td align=right><div align=right>Qt 3.3.8</div>
111</table></div></address></body>
112</html>
Note: See TracBrowser for help on using the repository browser.