File: chap2_4.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 (102 lines) | stat: -rw-r--r-- 5,227 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
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Putting It All Together</title>
		<meta name="generator" content="Adobe GoLive 4">
		<link rel="HOME" href="book1.html">
		<link rel="UP" title="Tutorial: Creating A Simple Application With The Help Of
	  Qt Designer" href="chap2_1.html">
		<link rel="PREVIOUS" title="Generating C++ Source Code From The Qt Designer File" href="chap2_3.html">
		<link rel="NEXT" title="Tutorial: Adding Functionality To A Dialog By
	  Subclassing" href="chap3_1.html">
		
	</head>

	<body class="SECT1" 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_3.html"><img height="20" width="20" src="arrows/left.png" border="0"></a></td>
					<td width="80%" align="center" valign="bottom"><font color="white"><b>Chapter 2. Tutorial: Creating A Simple Application With The Help Of Qt Designer</b></font></td>
					<td width="10%" align="right" valign="bottom"><a href="chap3_1.html"><img height="20" width="20" src="arrows/right.png" border="0"></a></td>
				</tr>
			</table>
		</div>
		<div class="SECT1">
			<h1 class="SECT1"><a name="AEN378"></a>Putting It All Together</h1>
			<p>Now that we have the code for our dialog, all we need is some test code to try it. The following code is about the simplest piece you can have:</p>
			<pre class="SCREEN">#include &lt;qapplication.h&gt;
#include &quot;PizzaEntry.h&quot;

int main( int argc, char* argv[] )
{
  QApplication app( argc, argv );

  PizzaEntryForm pizzaEntry;
  app.setMainWidget( &amp;pizzaEntry );
  pizzaEntry.show();

  int ret = app.exec();
  return ret;
}</pre>
			<p>Save this as <tt class="FILENAME">PizzaEntryTest.cpp</tt>. Now you can start building your program. On a Unix system with the g++ compiler, these could be your command lines:</p>
			<pre class="SCREEN">moc -o moc_PizzaEntry.cpp PizzaEntry.h
g++ -I$QTDIR/include PizzaEntry.cpp PizzaEntryTest.cpp &bsol;
moc_PizzaEntry.cpp -L$QTDIR/lib -lqt</pre>
			<p>and on a Windows system with the Microsoft Visual C++ compiler:</p>
			<pre class="SCREEN">moc -o moc_PizzaEntry.cpp PizzaEntry.h
cl -c -nologo -I%QTDIR%/include -FoPizzaEntry.obj PizzaEntry.cpp
cl -c -nologo -I%QTDIR%/include -FoPizzaEntryTest.obj PizzaEntryTest.cpp
cl -c -nologo -I%QTDIR%/include -Fomoc_PizzaEntry.obj moc_PizzaEntry.cpp
link /NOLOGO /SUBSYSTEM:windows /OUT:PizzaEntry PizzaEntry.obj PizzaEntryTest.obj &bsol;
    moc_PizzaEntry.obj %QTDIR%/lib/qt.lib kernel32.lib user32.lib gdi32.lib &bsol;
    comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
    imm32.lib winmm.lib wsock32.lib</pre>
			<p>If you use a different compiler, you might have to change the compiler command and some of the options. If you do not know what the line starting with <b class="COMMAND">moc</b> is for, please see the Qt Tutorial or <i class="EMPHASIS">Programming with Qt</i>.</p>
			<p>Finally, you can run your program. <a href="#QT-DESIGNER-FIG-PIZZA1SCREENSHOT">Figure 2-13</a> shows the result.</p>
			<div class="FIGURE">
				<a name="QT-DESIGNER-FIG-PIZZA1SCREENSHOT"></a>
				<p><b>Figure 2-13. Our first program in action</b></p>
				<p><img src="figures/pizza1screenshot.png"></p>
			</div>
		</div>
		<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_3.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_1.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">Generating C++ Source Code From The Qt Designer File</font></td>
					<td width="34%" align="center" valign="top"><a href="chap2_1.html"><img height="20" width="20" src="arrows/up.png" border="0"></a></td>
					<td width="33%" align="right" valign="top"><font  color="white">Tutorial: Adding Functionality To A Dialog By Subclassing</font></td>
				</tr>
			</table>
		</div>
	</body>

</html>