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"><!--
|
---|
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>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
|
---|
39 | and then create a <a href="qwidget.html">QWidget</a> form to be used as the extension. See
|
---|
40 | the 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
|
---|
45 | LANGUAGE = C++
|
---|
46 |
|
---|
47 | CONFIG += qt warn_on release
|
---|
48 |
|
---|
49 | REQUIRES = full-config nocrosscompiler
|
---|
50 |
|
---|
51 | SOURCES += main.cpp
|
---|
52 | FORMS = mainform.ui \
|
---|
53 | dialogform.ui \
|
---|
54 | extension.ui
|
---|
55 | DBFILE = 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 <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
71 | #include <<a href="qcheckbox-h.html">qcheckbox.h</a>>
|
---|
72 | #include <<a href="qlineedit-h.html">qlineedit.h</a>>
|
---|
73 |
|
---|
74 | void 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 |
|
---|
83 | void MainForm::optionsDlg()
|
---|
84 | {
|
---|
85 | DialogForm *dlg = new DialogForm( this, "dialog", TRUE );
|
---|
86 | Extension *ext = (Extension*)dlg->extension()->qt_cast( "Extension" );
|
---|
87 | if ( !ext )
|
---|
88 | return;
|
---|
89 | dlg->sessionsCheckBox->setChecked( sessions );
|
---|
90 | dlg->loggingCheckBox->setChecked( logging );
|
---|
91 | ext->logfileLineEdit->setText( log_filename );
|
---|
92 | ext->logErrorsCheckBox->setChecked( log_errors );
|
---|
93 |
|
---|
94 | if ( dlg->exec() ) {
|
---|
95 | sessions = dlg->sessionsCheckBox->isChecked();
|
---|
96 | logging = dlg->loggingCheckBox->isChecked();
|
---|
97 | log_filename = ext->logfileLineEdit->text();
|
---|
98 | log_errors = ext->logErrorsCheckBox->isChecked();
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | void 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 |
|
---|
117 | void DialogForm::init()
|
---|
118 | {
|
---|
119 | extensionShown = FALSE;
|
---|
120 | setExtension( new Extension( this ) );
|
---|
121 | setOrientation( Vertical );
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | void DialogForm::toggleDetails()
|
---|
126 | {
|
---|
127 | extensionShown = !extensionShown;
|
---|
128 | showExtension( extensionShown );
|
---|
129 | <a href="qstring.html">QString</a> text = tr( "&Details " );
|
---|
130 | text += QString( extensionShown ? "<<<" : ">>>" );
|
---|
131 | detailsPushButton->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 <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
147 | #include "mainform.h"
|
---|
148 |
|
---|
149 | int main( int argc, char ** argv )
|
---|
150 | {
|
---|
151 | <a href="qapplication.html">QApplication</a> a( argc, argv );
|
---|
152 | MainForm *w = new MainForm;
|
---|
153 | w->show();
|
---|
154 | <a name="x2868"></a><a name="x2867"></a> a.<a href="qobject.html#connect">connect</a>( &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 © 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>
|
---|