diff options
author | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /doc/html/qmake-manual-7.html | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'doc/html/qmake-manual-7.html')
-rw-r--r-- | doc/html/qmake-manual-7.html | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/doc/html/qmake-manual-7.html b/doc/html/qmake-manual-7.html new file mode 100644 index 000000000..8c71e939f --- /dev/null +++ b/doc/html/qmake-manual-7.html @@ -0,0 +1,206 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/qmake/book/qmake-pch.leaf:3 --> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Using Precompiled Headers</title> +<style type="text/css"><!-- +fn { margin-left: 1cm; text-indent: -1cm; } +a:link { color: #004faf; text-decoration: none } +a:visited { color: #672967; text-decoration: none } +body { background: #ffffff; color: black; } +--></style> +</head> +<body> + +<table border="0" cellpadding="0" cellspacing="0" width="100%"> +<tr bgcolor="#E5E5E5"> +<td valign=center> + <a href="index.html"> +<font color="#004faf">Home</font></a> + | <a href="classes.html"> +<font color="#004faf">All Classes</font></a> + | <a href="mainclasses.html"> +<font color="#004faf">Main Classes</font></a> + | <a href="annotated.html"> +<font color="#004faf">Annotated</font></a> + | <a href="groups.html"> +<font color="#004faf">Grouped Classes</font></a> + | <a href="functions.html"> +<font color="#004faf">Functions</font></a> +</td> +<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><p align="right">[<a href="qmake-manual-6.html">Prev: qmake's Advanced Concepts</a>] [<a href="qmake-manual.html">Home</a>] [<a href="qmake-manual-8.html">Next: qmake Command Reference</a>]</p> +<h2 align="center">Using Precompiled Headers</h2> +<a name="About"></a><h3><a name="1"></a>About Precompiled Headers<!-- index About Precompiled Headers --><!-- index Using Precompiled Headers --><!-- index Precompiled Headers --><!-- index PCH --></h3> +<p>Precompiled headers are a performance feature supported by some compilers to compile a stable body of code, and store the compiled state of the code in a binary file. During subsequent compilations, the compiler will load the stored state, and continue compiling the specified file. Each subsequent compilation is faster because the stable code does not need to be recompiled.</p> +<p><em>qmake</em> supports the use of precompiled headers (PCH) on some platforms and build environments, including:</p> +<ul><li><p>Windows</p> +<ul><li><p>nmake</p> +<li><p>Dsp projects (VC 6.0)</p> +<li><p>Vcproj projects (VC 7.0 & 7.1)</p> +</ul><li><p>Mac OS X</p> +<ul><li><p>Makefile</p> +<li><p>Xcode</p> +<li><p>GCC 3.3 and up</p> +</ul><li><p>Unix</p> +<ul><li><p>GCC 3.4 and up</p> +</ul></ul><a name="ADD_PCH"></a><h3><a name="2"></a>Adding PCH to your project</h3> +<a name="PCH_CONTENTS"></a><h4><a name="2-1"></a>Contents of the precompiled header file</h4> +<p>The precompiled header must contain code which is <em>stable</em> and <em>static</em> throughout your project. A typical PCH might look like this:</p> +<h5><a name="2-1-1"></a>stable.h</h5> +<pre> + /* Add C includes here */ + + #if defined __cplusplus + /* Add C++ includes here */ + #include <stdlib> + #include <iostream> + #include <vector> + #include <qapplication.h> // TQt includes + #include <qpushbutton.h> + #include <qlabel.h> + #include "thirdparty/include/libmain.h" + #include "my_stable_class.h" + ... + #endif +</pre> +<p>Note that a precompiled header file needs to separate C includes from CPP includes, since the precompiled header file for C files may not contain C++ code.</p> +<a name="PROJECT_OPTIONS"></a><h4><a name="2-2"></a>Project options</h4> +<p>To make your project use PCH, the only thing you need to change in your project settings (.pro), is to include the PRECOMPILED_HEADER option:</p> +<pre> + PRECOMPILED_HEADER = stable.h +</pre> +<p><em>qmake</em> will handle the rest, to ensure the creation and use of the precompiled header file. You do not need to include the precompiled header file in HEADERS, as qmake will do this if the configuration supports PCH.</p> +<p>All platforms that support precompiled headers have the configuration option <b>precompile_header</b> set. Using this option, you may trigger conditional blocks in your .pro file, to add settings when using PCH. For example:</p> +<pre> + precompile_header:!isEmpty(PRECOMPILED_HEADER) { + DEFINES += USING_PCH + } + +</pre> +<a name="EXAMPLE_PROJECT"></a><h3><a name="3"></a>Example project</h3> +<p>You can find the following source code in the <em>qt/qmake/examples/precompile</em> directory:</p> +<p><b>mydialog.ui</b></p> +<pre> <!DOCTYPE UI><UI version="3.3" stdsetdef="1"> + <class>MyDialog</class> + <widget class="TQDialog"> + <property name="name"> + <cstring>MyDialog</cstring> + </property> + <property name="caption"> + <string>Mach 2!</string> + </property> + <vbox> + <widget class="TQLabel"> + <property name="name"> + <cstring>aLabel</cstring> + </property> + <property name="text"> + <string>Join the life in the fastlane; - PCH enable your project today! -</string> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>aButton</cstring> + </property> + <property name="text"> + <string>&amp;Quit</string> + </property> + <property name="accel"> + <string>Alt+Q</string> + </property> + </widget> + </vbox> + </widget> + </UI> +</pre> + <p><b>stable.h</b></p> +<pre> /* Add C includes here */ + + #if defined __cplusplus + /* Add C++ includes here */ + + # include <iostream> + # include <qapplication.h> + # include <qpushbutton.h> + # include <qlabel.h> + #endif +</pre> + <p><b>myobject.h</b></p> +<pre> #include <<a href="qobject-h.html">qobject.h</a>> + + class MyObject : public <a href="qobject.html">TQObject</a> + { + public: + MyObject(); + ~MyObject(); + }; +</pre> + <p><b>myobject.cpp</b></p> +<pre> #include <iostream> + #include <<a href="qobject-h.html">qobject.h</a>> + #include "myobject.h" + + MyObject::MyObject() + : <a href="qobject.html">TQObject</a>() + { + std::cout << "MyObject::MyObject()\n"; + } +</pre> + <p><b>util.cpp</b></p> +<pre> void util_function_does_nothing() + { + // Nothing here... + int x = 0; + ++x; + } +</pre> + <p><b>main.cpp</b></p> +<pre> #include <<a href="qapplication-h.html">qapplication.h</a>> + #include <<a href="qpushbutton-h.html">qpushbutton.h</a>> + #include <<a href="qlabel-h.html">qlabel.h</a>> + #include "myobject.h" + #include "mydialog.h" + + int main(int argc, char **argv) + { + <a href="qapplication.html">TQApplication</a> app(argc, argv); + + MyObject obj; + MyDialog dia; + app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &dia ); + dia.connect( dia.aButton, SIGNAL(clicked()), SLOT(<a href="qwidget.html#close">close</a>()) ); + dia.show(); + + return app.<a href="qapplication.html#exec">exec</a>(); + } +</pre> + <p><b>precompile.pro</b></p> +<pre> ############################################# + # + # Example for using Precompiled Headers + # + ############################################# + TEMPLATE = app + LANGUAGE = C++ + CONFIG += console precompile_header + + # Use Precompiled headers (PCH) + PRECOMPILED_HEADER = stable.h + + HEADERS += stable.h \ + myobject.h + SOURCES += main.cpp \ + myobject.cpp \ + util.cpp + FORMS = mydialog.ui +</pre> +<!-- eof --> +<p align="right">[<a href="qmake-manual-6.html">Prev: qmake's Advanced Concepts</a>] [<a href="qmake-manual.html">Home</a>] [<a href="qmake-manual-8.html">Next: qmake Command Reference</a>]</p> +<p><address><hr><div align=center> +<table width=100% cellspacing=0 border=0><tr> +<td>Copyright © 2007 +<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> +<td align=right><div align=right>TQt 3.3.8</div> +</table></div></address></body> +</html> |