source: trunk/doc/html/extension-dialog-example.html

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

reference documentation added

File size: 6.0 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/examples/extension/extension.doc:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>An Extension Dialog Example</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>An Extension Dialog Example</h1>
33
34
35
36<p>
37<p> This example demonstrates how to create an extension dialog.
38<p> Essentially all that is necessary is to create a standard dialog
39and then create a <a href="qwidget.html">QWidget</a> form to be used as the extension. See
40the article in <a href="http://doc.trolltech.com/qq/">Qt
41 Quarterly</a> issue #3.
42<p> <hr>
43<p> Project file:
44<p> <pre>TEMPLATE = app
45LANGUAGE = C++
46
47CONFIG += qt warn_on release
48
49REQUIRES = full-config nocrosscompiler
50
51SOURCES += main.cpp
52FORMS = mainform.ui \
53 dialogform.ui \
54 extension.ui
55DBFILE = extension.db
56</pre>
57
58<p> <hr>
59<p> <hr>
60<p> Implementation:
61<p> <pre>/****************************************************************************
62** ui.h extension file, included from the uic-generated form implementation.
63**
64** If you wish to add, delete or rename functions use Qt Designer which will
65** update this file, preserving your code. Create an init() function in place
66** of a constructor, and a destroy() function in place of a destructor.
67*****************************************************************************/
68#include "dialogform.h"
69#include "extension.h"
70#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
71#include &lt;<a href="qcheckbox-h.html">qcheckbox.h</a>&gt;
72#include &lt;<a href="qlineedit-h.html">qlineedit.h</a>&gt;
73
74void MainForm::init()
75{
76 sessions = FALSE;
77 logging = FALSE;
78 log_filename = <a href="qstring.html#QString-null">QString::null</a>;
79 log_errors = TRUE;
80 log_actions = TRUE;
81}
82
83void MainForm::optionsDlg()
84{
85 DialogForm *dlg = new DialogForm( this, "dialog", TRUE );
86 Extension *ext = (Extension*)dlg-&gt;extension()-&gt;qt_cast( "Extension" );
87 if ( !ext )
88 return;
89 dlg-&gt;sessionsCheckBox-&gt;setChecked( sessions );
90 dlg-&gt;loggingCheckBox-&gt;setChecked( logging );
91 ext-&gt;logfileLineEdit-&gt;setText( log_filename );
92 ext-&gt;logErrorsCheckBox-&gt;setChecked( log_errors );
93
94 if ( dlg-&gt;exec() ) {
95 sessions = dlg-&gt;sessionsCheckBox-&gt;isChecked();
96 logging = dlg-&gt;loggingCheckBox-&gt;isChecked();
97 log_filename = ext-&gt;logfileLineEdit-&gt;text();
98 log_errors = ext-&gt;logErrorsCheckBox-&gt;isChecked();
99 }
100}
101
102
103void MainForm::quit()
104{
105<a name="x2865"></a> QApplication::<a href="qapplication.html#exit">exit</a>( 0 );
106}
107</pre>
108
109<pre>/****************************************************************************
110** ui.h extension file, included from the uic-generated form implementation.
111**
112** If you wish to add, delete or rename functions use Qt Designer which will
113** update this file, preserving your code. Create an init() function in place
114** of a constructor, and a destroy() function in place of a destructor.
115*****************************************************************************/
116
117void DialogForm::init()
118{
119 extensionShown = FALSE;
120 setExtension( new Extension( this ) );
121 setOrientation( Vertical );
122}
123
124
125void DialogForm::toggleDetails()
126{
127 extensionShown = !extensionShown;
128 showExtension( extensionShown );
129 <a href="qstring.html">QString</a> text = tr( "&amp;Details " );
130 text += QString( extensionShown ? "&lt;&lt;&lt;" : "&gt;&gt;&gt;" );
131 detailsPushButton-&gt;setText( text );
132}
133</pre>
134
135<pre>/****************************************************************************
136** ui.h extension file, included from the uic-generated form implementation.
137**
138** If you wish to add, delete or rename functions use Qt Designer which will
139** update this file, preserving your code. Create an init() function in place
140** of a constructor, and a destroy() function in place of a destructor.
141*****************************************************************************/
142</pre>
143
144<p> <hr>
145<p> Main:
146<p> <pre>#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
147#include "mainform.h"
148
149int main( int argc, char ** argv )
150{
151 <a href="qapplication.html">QApplication</a> a( argc, argv );
152 MainForm *w = new MainForm;
153 w-&gt;show();
154<a name="x2868"></a><a name="x2867"></a> a.<a href="qobject.html#connect">connect</a>( &amp;a, SIGNAL( <a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>() ), w, SLOT( quit() ) );
155 return a.<a href="qapplication.html#exec">exec</a>();
156}
157</pre>
158
159<p> <p>See also <a href="step-by-step-examples.html">Step-by-step Examples</a>.
160
161<!-- eof -->
162<p><address><hr><div align=center>
163<table width=100% cellspacing=0 border=0><tr>
164<td>Copyright &copy; 2007
165<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
166<td align=right><div align=right>Qt 3.3.8</div>
167</table></div></address></body>
168</html>
Note: See TracBrowser for help on using the repository browser.