[190] | 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/doc/tutorial2.doc:322 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>Mainly Easy</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>Mainly Easy</h1>
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | <p>
|
---|
| 36 | <p> (<tt>main.cpp</tt>.)
|
---|
| 37 | <p>
|
---|
| 38 |
|
---|
| 39 | <pre> #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
| 40 | #include "chartform.h"
|
---|
| 41 |
|
---|
| 42 | int main( int argc, char *argv[] )
|
---|
| 43 | {
|
---|
| 44 | <a href="qapplication.html">QApplication</a> app( argc, argv );
|
---|
| 45 |
|
---|
| 46 | <a href="qstring.html">QString</a> filename;
|
---|
| 47 | <a name="x2557"></a> if ( app.<a href="qapplication.html#argc">argc</a>() > 1 ) {
|
---|
| 48 | <a name="x2558"></a> filename = app.<a href="qapplication.html#argv">argv</a>()[1];
|
---|
| 49 | <a name="x2561"></a> if ( !filename.<a href="qstring.html#endsWith">endsWith</a>( ".cht" ) )
|
---|
| 50 | filename = <a href="qstring.html#QString-null">QString::null</a>;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | ChartForm *cf = new ChartForm( filename );
|
---|
| 54 | <a name="x2560"></a> app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( cf );
|
---|
| 55 | cf-><a href="qwidget.html#show">show</a>();
|
---|
| 56 |
|
---|
| 57 | return app.<a href="qapplication.html#exec">exec</a>();
|
---|
| 58 | }
|
---|
| 59 | </pre>
|
---|
| 60 | <p> We have kept the main() function simple and small. We create a
|
---|
| 61 | <a href="qapplication.html">QApplication</a> object and pass it the command line arguments. We are
|
---|
| 62 | allowing users to invoke the program with <tt>chart mychart.cht</tt>, so if
|
---|
| 63 | they've added a filename we pass that through to the chart form
|
---|
| 64 | constructor. Most of the action takes place within the chart form
|
---|
| 65 | which we'll review next.
|
---|
| 66 | <p> <p align="right">
|
---|
| 67 | <a href="tutorial2-03.html">« Data Elements</a> |
|
---|
| 68 | <a href="tutorial2.html">Contents</a> |
|
---|
| 69 | <a href="tutorial2-05.html">Presenting the GUI »</a>
|
---|
| 70 | </p>
|
---|
| 71 | <p>
|
---|
| 72 | <!-- eof -->
|
---|
| 73 | <p><address><hr><div align=center>
|
---|
| 74 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 75 | <td>Copyright © 2007
|
---|
| 76 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 77 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 78 | </table></div></address></body>
|
---|
| 79 | </html>
|
---|