source: trunk/doc/html/motif-walkthrough-4.html@ 208

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

reference documentation added

File size: 4.6 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/extensions/motif/doc/walkthrough.doc:561 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Using Custom QDialogs</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>Using Custom QDialogs</h1>
33
34
35
36[ <a href="motif-walkthrough-3.html">Previous: Using Qt Standard Dialogs</a> ]
37[ <a href="motif-walkthrough.html">Home</a> ]
38[ <a href="motif-walkthrough-5.html">Next: Using Existing Dialogs with QMotifDialog</a> ]
39<p> After we have replaced the standard dialogs, we move onto the custom
40dialogs. This project has a single custom dialog: the <em>Page Edit</em>
41dialog.
42<p> Instead of writing the code ourselves, we use <a href="designer-manual.html">Qt Designer</a> to design our dialog.
43Designing a custom dialog is beyond the scope of
44this document: see the <a href="designer-manual.html">Qt Designer Manual</a> if you're unfamiliar
45with Qt's visual design tool.
46<p> <h2> Replacing the <em>Page Edit</em> Dialog
47</h2>
48<a name="1"></a><p> The custom <a href="qdialog.html">QDialog</a> description for the <em>Page Edit</em> dialog is saved
49as <tt>pageeditdialog.ui</tt>. We add this file to the project file by
50adding the line
51<pre>
52FORMS = pageeditdialog.ui
53</pre>
54
55to the <tt>.pro</tt> file, and regenerate the <tt>Makefile</tt>. The <em>uic</em>
56utility generates the code for our custom QDialog, which is then
57compiled and linked into our application. (<em>uic</em> is invoked
58automatically from makefiles generated from <tt>.pro</tt> files.)
59<p> We need to pass the top-level <a href="qmotifwidget.html">QMotifWidget</a> as the <em>client_data</em>
60argument to the <tt>EditPage</tt> function, which we will use as the parent
61for our new <tt>PageEditDialog</tt>. We do this the same way as we have
62done for the <em>Open</em> and <em>Save As</em> dialogs in <tt>todo.cpp</tt>.
63<p>
64
65<p> <pre></pre>
66<p> The <tt>EditPage()</tt> function is implemented in <tt>actions.cpp</tt>. We start
67by adding the includes needed for the <tt>PageEditDialog</tt> and <a href="qlineedit.html">QLineEdit</a>.
68<p>
69
70<p> <pre></pre>
71<p> In the <tt>EditPage()</tt> function, We create the <tt>PageEditDialog</tt>, set
72the initial values of the three QLineEdit widgets with values from the
73current page and execute the dialog.
74<p> <pre></pre><pre>
75 ...
76</pre>
77
78<p> At this point in the code, the page properties should be modified. The
79code to do this is in the <tt>DoEditPage()</tt> function. We move the
80contents of <tt>DoEditPage()</tt> to this point and remove the <tt>DoEditPage()</tt> function completely.
81<p> The <tt>Page</tt> struct defined in <tt>page.h</tt> stores strings in <tt>char*</tt>
82arrays. Since the PageEditDialog and the data it contains will be
83destroyed when we return from this function, we need to convert the
84unicode <a href="qstring.html">QString</a> data into a <a href="qcstring.html">QCString</a> in the local encoding and
85duplicate it with <a href="qcstring.html#qstrdup">qstrdup</a>().
86<p> <pre></pre>
87<p> The same process must be done for the minorTab text:
88<p> <pre></pre>
89<p> ... and for the majorTab text:
90<p> <pre></pre>
91<p> [ <a href="motif-walkthrough-3.html">Previous: Using Qt Standard Dialogs</a> ]
92[ <a href="motif-walkthrough.html">Home</a> ]
93[ <a href="motif-walkthrough-5.html">Next: Using Existing Dialogs with QMotifDialog</a> ]
94<p>
95<!-- eof -->
96<p><address><hr><div align=center>
97<table width=100% cellspacing=0 border=0><tr>
98<td>Copyright &copy; 2007
99<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
100<td align=right><div align=right>Qt 3.3.8</div>
101</table></div></address></body>
102</html>
Note: See TracBrowser for help on using the repository browser.