File: chap3_1.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (105 lines) | stat: -rw-r--r-- 6,932 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Tutorial: Adding Functionality To A Dialog By Subclassing</title>
		<meta name="generator" content="Adobe GoLive 4">
		<link rel="HOME" href="book1.html">
		<link rel="UP" title="Qt Designer Tutorial and User's Manual" href="part1index.html">
		<link rel="PREVIOUS" title="Putting It All Together" href="chap2_4.html">
		<link rel="NEXT" title="Adding Functionality To The Push Buttons" href="chap3_2.html">
		
	</head>

	<body class="CHAPTER" bgcolor="white" text="black" link="blue" vlink="#840084" alink="blue">
		<div class="NAVHEADER">
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td width="500" align="left" valign="middle"><img height="90" width="475" src="figures/title.png" border="0"></td>
					<td></td>
					<td align="right" valign="top"> <a href="../company/about/trolls.html">
						<table border="0" cellpadding="0" cellspacing="0" width="137">
							<tr>
								<td><img height="100" width="100" src="figures/f001.png" border="0"></td>
								<td><img height="100" width="100" src="figures/qtlogo.png" align="top" border="0"></td>
							</tr>
						</table>
						</a></td>
				</tr>
				<tr>
					<td width="500"><spacer type="block" width="500" height="20"></td>
					<td><spacer type="block" width="42" height="20"></td>
					<td><br>
					</td>
				</tr>
			</table>
			<table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="black">
				<tr>
					<td width="10%" align="left" valign="bottom"> <a href="chap2_4.html"><img height="20" width="20" src="arrows/left.png" border="0"></a></td>
					<td width="80%" align="center" valign="bottom"><br>
					</td>
					<td width="10%" align="right" valign="bottom"> <a href="chap3_2.html"><img height="20" width="20" src="arrows/right.png" border="0"></a></td>
				</tr>
			</table>
		</div>
		<div class="CHAPTER">
			<h1><a name="AEN399"></a>Chapter 3. Tutorial: Adding Functionality To A Dialog By Subclassing</h1>
			<div class="TOC">
				<dl>
					<dt><b>Table of Contents</b>
					<dt> <a href="#AEN404">Continuing Work On An Already Existing Dialog</a>
					<dt> <a href="chap3_2.html">Adding Functionality To The Push Buttons</a>
					<dt> <a href="chap3_3.html">Initializing The State Of Widgets In The Form</a>
					<dt> <a href="chap3_4.html">Connecting Widgets To Each Other</a>
				</dl>
			</div>
			<p>In this chapter, we will build on the pizza entry form presented in the last chapter and augment it. You will learn how to continue work on an already existing dialog and how to add functionality to the dialog classes that Qt Designer creates for you.</p>
			<div class="SECT1">
				<h1 class="SECT1"><a name="AEN404"></a>Continuing Work On An Already Existing Dialog</h1>
				<p>Once you have run your application, you might notice that your dialog still needs work. This is no problem at all. All you have to do is start Qt Designer again (in case you have shut it down in the meantime) and load the <tt class="FILENAME">.ui</tt> file via the menu entry <span class="GUIMENU">File/Open</span> or the load button on the toolbar (see <a href="#QT-DESIGNER-ICON-LOAD">Figure 3-1</a>). If you use Windows or the K Desktop Environment on a Unix system, you can also drag an icon representing a <tt class="FILENAME">.ui</tt> file from an Explorer/Konqueror window or the desktop onto the Qt Designer window and drop it there.</p>
				<div class="FIGURE">
					<a name="QT-DESIGNER-ICON-LOAD"></a>
					<p><b>Figure 3-1. The load icon</b></p>
					<p><img src="figures/load.png"></p>
				</div>
				<p>You will see your form as you have left it. Qt Designer does not care about any generated source files; all it uses, both when saving and when loading, are the XML-based <tt class="FILENAME">.ui</tt> files. <a href="#FTN.AEN426" name="AEN426">[1]</a></p>
				<p>This behavior of Qt Designer has one important consequence: Never change the files generated by <b class="COMMAND">uic</b>! Any changes will be lost once you change the <tt class="FILENAME">.ui</tt> file, save it, and rerun <b class="COMMAND">uic</b>. If you need to change some of the generated code&#151;e.g., because you want to add some functionality&#151;you have to do this by subclassing. We'll see in a minute how to do that, but first let's define the objectives of this tutorial:</p>
				<ul>
					<li>
					<p>The <span class="GUILABEL">OK</span> and <span class="GUILABEL">Cancel</span> buttons should actually close the dialog; when the <span class="GUILABEL">OK</span> button is pressed, a message box should inform the user that the order has been sent to the pizza place.</p>
					<li>
					<p>Since our pizza service wants to have as much turnover as possible, we want all the toppings and the <span class="GUILABEL">Family</span> size to be selected by default. If you tried the dialog from the previous chapter, you might have noticed that no size was selected from the beginning, which of course is bad, since the customer might forget to select one.</p>
					<li>
					<p>Turnover is pretty low on Mondays, so to increase the number of orders, our pizza service provides extra cheese without additional cost on Mondays. As a courtesy to the user, we want to check the extra cheese check box on Mondays but leave it unchecked on all other days.</p>
				</ul>
				<p>We will now implement these features one by one.</p>
			</div>
		</div>
		<h3 class="FOOTNOTES">Notes</h3>
		<p>
		<table border="0" class="FOOTNOTES" width="100%">
			<tr>
				<td align="left" valign="top" width="5%"> <a href="#AEN426" name="FTN.AEN426">[1]</a></td>
				<td align="left" valign="top" width="95%">Or <b class="COMMAND">tmake</b> project files, as you will learn in the section called <a href="chap5_4.html#USINGTMAKE"><i>Using tmake For Generating And Building Qt Designer Files</i></a> in Chapter 5.</td>
			</tr>
		</table>
		</p>
		<div class="NAVFOOTER">
			<br>
			<br>
			<table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="black">
				<tr>
					<td width="33%" align="left" valign="top"> <a href="chap2_4.html"><img height="20" width="20" src="arrows/left.png" border="0"></a></td>
					<td width="34%" align="center" valign="top"> <a href="book1.html"><img height="20" width="25" src="arrows/home.png" border="0"></a></td>
					<td width="33%" align="right" valign="top"> <a href="chap3_2.html"><img height="20" width="20" src="arrows/right.png" border="0"></a></td>
				</tr>
				<tr>
					<td width="33%" align="left" valign="top"><font  color="white">Putting It All Together</font></td>
					<td width="34%" align="center" valign="top"> <a href="part1index.html"><img height="20" width="20" src="arrows/up.png" border="0"></a></td>
					<td width="33%" align="right" valign="top"><font  color="white">Adding Functionality To The Push Buttons</font></td>
				</tr>
			</table>
		</div>
	</body>

</html>