<li><p>Chapter two, <ahref="designer-manual-3.html">Creating a Main Window Application</a>, introduces <em>TQt Designer</em> and takes you step by step through the creation of a small but fully functional application. Along the way you will learn how to create a main window with menus, toolbars and a status bar. Most of the application's implementation will be covered, but the custom dialogs are deferred until chapter three. In the course of this chapter you will use the form and property editors to customize the application. You'll also learn how to use TQt's signals and slots mechanism and <em>TQt Designer</em>'s built-in code editor to make the application functional. We will also explain how to use <tt>qmake</tt> to generate a Makefile so that you can compile and run the application.</p>
<li><p>In chapter three, <ahref="designer-manual-4.html">Creating Dialogs</a>, we will create the custom dialogs required by the main window application created in chapter two. In addition to demonstrating various ways of creating dialogs, you will also learn how to lay out forms using the layout tools.</p>
<li><p>Chapter four, <ahref="designer-manual-5.html#the-designer-approach">The Designer Approach</a>, provides information on the <em>TQt Designer</em> approach to developing applications, and explains some of the rationale behind <em>TQt Designer</em>.</p>
<li><p>Chapter five, <ahref="designer-manual-6.html">Subclassing and Dynamic Dialogs</a>, will show you how to subclass a form; this allows you to clearly separate the user interface from the underlying code that implements its functionality. Additional information on <tt>qmake</tt> and <tt>uic</tt> is included in this chapter. This chapter will also explain how you can dynamically load dialogs from<!-- index .ui --><tt>.ui</tt> files into your application using <ahref="tqwidgetfactory.html">TQWidgetFactory</a> and how to access the widgets and sub-widgets of these dialogs.</p>
<li><p>Chapter five, <ahref="designer-manual-6.html">Subclassing and Dynamic Dialogs</a>, will show you how to subclass a form; this allows you to clearly separate the user interface from the underlying code that implements its functionality. Additional information on <tt>qmake</tt> and <tt>tquic</tt> is included in this chapter. This chapter will also explain how you can dynamically load dialogs from<!-- index .ui --><tt>.ui</tt> files into your application using <ahref="tqwidgetfactory.html">TQWidgetFactory</a> and how to access the widgets and sub-widgets of these dialogs.</p>
<li><p>Chapter six, <ahref="designer-manual-7.html">Creating Custom Widgets</a>, explains how you can create your own custom widgets. Both the simple method, that was introduced with the first version of <em>TQt Designer</em>, and the new more powerful method using plugins, are explained.</p>
<li><p>Chapter seven, <ahref="designer-manual-8.html">Creating Database Applications</a> introduces TQt's SQL classes and takes you through an example that demonstrates how to execute SQL queries and how to set up master-detail relationships, perform drilldown and handle foreign keys.</p>
<li><p>Chapter eight, <ahref="designer-manual-9.html">Customizing and Integrating TQt Designer</a>, focuses on <em>TQt Designer</em> itself, showing you how to customize Designer, how to integrate Designer with Visual Studio and how to create Makefiles.</p>
<p>The 'Insert Into' drop-down combobox lists the open projects, defaulting to the current project. New files are added to the project displayed in this combobox. To add a new file to a different project, choose the project you want to use in the 'Insert Into' combobox.</p>
<p>The 'Dialog' file type is highlighted by default when the <em>New File</em> dialog pops up. Click on the file type you want to use and click <b>OK</b> to create it. Click <b>Cancel</b> to leave the dialog without creating a new file. Note that if you select C++ Project, the 'Insert Into' combobox will be disabled, since it is not possible to insert a new C++ Project into an existing project.</p>
<h5><aname="3-1-1"></a>C++ Project Files</h5>
<p>Click <b>C++ Project</b> to start a new project. This option invokes the <ahref="designer-manual-13.html#5-4">Project Settings Dialog</a>. C++ projects are saved as <tt>.pro</tt> files, which include the information <em>TQt Designer</em> needs to manage projects. When you add a form to your project in <em>TQt Designer</em>, it is automatically added to the FORMS section of the project file. The <tt>.pro</tt> file contains the list of forms (<tt>.ui</tt> files) used in the project. <em>TQt Designer</em> reads and writes <tt>.ui</tt> files, e.g. form.ui. The uic (user interface compiler) creates both a header file, e.g. form.h, and an implementation file, e.g. form.cpp, from the <tt>.ui</tt> file.</p>
<p>Click <b>C++ Project</b> to start a new project. This option invokes the <ahref="designer-manual-13.html#5-4">Project Settings Dialog</a>. C++ projects are saved as <tt>.pro</tt> files, which include the information <em>TQt Designer</em> needs to manage projects. When you add a form to your project in <em>TQt Designer</em>, it is automatically added to the FORMS section of the project file. The <tt>.pro</tt> file contains the list of forms (<tt>.ui</tt> files) used in the project. <em>TQt Designer</em> reads and writes <tt>.ui</tt> files, e.g. form.ui. The tquic (user interface compiler) creates both a header file, e.g. form.h, and an implementation file, e.g. form.cpp, from the <tt>.ui</tt> file.</p>
<h5><aname="3-1-2"></a>Dialog Forms</h5>
<p>Click <b>Dialog</b> to create a plain dialog form. Typically, this type of form is used to present the user with configuration options, or to present related sets of choices, for example, printer setting dialogs and find and replace dialogs.</p>
<p>In the Settings section, you can change or add the name of the class that will be created by typing in the 'Class Name' line edit. Note that the default name is the form name, but it can be changed. You can also enter text to the 'Comment' and 'Author' line edits or leave them blank, since they are not required.</p>
<h5><aname="4-3-2"></a>Pixmaps</h5>
<p>The default (for projects) is 'Project Imagefile'. This is the recommended option. Images are handled automatically, with <em>TQt Designer</em> storing the images in a subdirectory, and <tt>uic</tt> producing code that contains the images and the necessary supporting code. Each image is stored just once, no matter how many forms it is used in.</p>
<p>The default (for projects) is 'Project Imagefile'. This is the recommended option. Images are handled automatically, with <em>TQt Designer</em> storing the images in a subdirectory, and <tt>tquic</tt> producing code that contains the images and the necessary supporting code. Each image is stored just once, no matter how many forms it is used in.</p>
<p>If you do not want <em>TQt Designer</em> to handle the images, (or are not using a project) choose either 'Save Inline' or 'Use Function'. 'Save Inline' saves the pixmaps in the <tt>.ui</tt> files. The disadvantage of this approach is that it stores images in the forms in which they're used, meaning that images cannot be shared across forms. Click 'Use Function' to use your own icon-loader function for loading pixmaps. Type the function's name (with no signature) in the 'Use Function' line edit. This function will be used in the generated code for loading pixmaps. Your function will be called with the text you put in the pixmap property (e.g. the image name) whenever an image is required.</p>
<h5><aname="4-3-3"></a>Layouts</h5>
<p>Click the 'Default Margin' spinbox or the 'Default Spacing' spinbox to change the default layout settings of the current form.</p>
<p>If you have a class that requires some Windows-specific export macro, e.g. for classes in a DLL that need to be declared like this: <tt>class win_specific_declaration_goes_here Class</tt>, you can use the <tt><exportmacro></tt> tag. (In standard TQt we use the <tt>TQ_EXPORT</tt> macro, e.g. <tt>class TQ_EXPORT TQWidget</tt>.) If you use this tag you must also:</p>
<oltype=1><li><p><ahref="designer-manual-16.html#1-11">include</a> the file which contains the macro definition;</p>
<li><p>add the export macro to the form -- this is achieved by entering the macro's name in the 'export macro' sub-property of the form's name property.</p>
</ol><p>Following these steps will ensure that <ahref="uic.html">uic</a> will create the correct <tt>class YOUR_MACRO Form</tt> declarations.</p>
</ol><p>Following these steps will ensure that <ahref="tquic.html">tquic</a> will create the correct <tt>class YOUR_MACRO Form</tt> declarations.</p>
<p>In TQt 2.x, <em>TQt Designer</em> was a visual form designer for editing files in the <tt>.ui</tt> file format. <em>TQt Designer</em>'s primary goal was to turn the most tedious part of GUI programming -- dialog design -- into a pleasant experience. From an architectural point of view, <em>TQt Designer</em> in 2.x is a fairly simple program. It reads and writes <tt>.ui</tt> files. Each <tt>.ui</tt> file contains an XML description of a single dialog form. A second utility -- the user interface compiler <tt>uic</tt> -- is used during the build process of an application to generate C++ code from those XML descriptions.</p>
<p>In TQt 2.x, <em>TQt Designer</em> was a visual form designer for editing files in the <tt>.ui</tt> file format. <em>TQt Designer</em>'s primary goal was to turn the most tedious part of GUI programming -- dialog design -- into a pleasant experience. From an architectural point of view, <em>TQt Designer</em> in 2.x is a fairly simple program. It reads and writes <tt>.ui</tt> files. Each <tt>.ui</tt> file contains an XML description of a single dialog form. A second utility -- the user interface compiler <tt>tquic</tt> -- is used during the build process of an application to generate C++ code from those XML descriptions.</p>
<p>For TQt 3.0 our ambitions for <em>TQt Designer</em> have grown beyond single dialog editing. In addition to many new design features like the ability to creating main windows and actions, the new version introduces:</p>
<ul><li><p><em>project management</em> for the user interface part of your application;</p>
<li><p><em>code in forms</em><em>TQt Designer</em> provides a code editor so that you can code your slots directly; the code is stored in <tt>.ui.h</tt> files and eliminates the need for sub-classing (although you can still subclass if you prefer);</p>
<p>When you've opened or created a project you can set up its database connections using the <em>Edit Database Connections</em> dialog (invoked by the <b>Project|Database Connections</b> menu option). The connections you make are stored in a <tt>.db</tt> file. When you reload a project you can reconnect by going to the <em>Edit Database Connections</em> dialog, clicking a connection in the list and clicking the <b>Connect</b> button.</p>
<p>In most non-trivial database applications you will want to access the database from more than one form. This is why the <tt>.db</tt> file is part of a project, not just part of a single form.</p>
<h4><aname="2-4"></a>.pro files</h4>
<p><em>TQt Designer</em> needs to store information on projects, for example, the list of forms, the image collection and information about available databases and how to access them. The majority of TQt users already use a project file format to create multiplatform makefiles: <tt>tmake</tt> (and with TQt 3.0 <tt>qmake</tt>) project <tt>.pro</tt> files. These files already contain the list of forms, <tt>.ui</tt> files, used in the project for <tt>uic</tt>.</p>
<p><em>TQt Designer</em> needs to store information on projects, for example, the list of forms, the image collection and information about available databases and how to access them. The majority of TQt users already use a project file format to create multiplatform makefiles: <tt>tmake</tt> (and with TQt 3.0 <tt>qmake</tt>) project <tt>.pro</tt> files. These files already contain the list of forms, <tt>.ui</tt> files, used in the project for <tt>tquic</tt>.</p>
<p>We've extended the sections in the <tt>.pro</tt> file to include the extra information that <em>TQt Designer</em> needs to manage projects. For example, when you add a form to your project in <em>TQt Designer</em>, it is automatically added to the FORMS section of the project file, and thus <tt>qmake</tt> will generate the required build rules without any further work. Similarly, the images are added to the IMAGES section and thus gets automatically compiled into your executable.</p>
<p>We don't force you to use <tt>qmake</tt>; if you prefer another build system, for example automake/autoconf or jam, you can still continue to use it. Look upon the <tt>.pro</tt> file as a file that describes the GUI part of your application. All you need to do -- as previously -- is add the <tt>.ui</tt> files and the images collection to your own Makefiles.</p>
<h3><aname="3"></a>Extending the functionality of a form</h3>
<p>First let us look at a small figure that shows the relationship between <tt>.ui</tt> files, generated code and application code:</p>
<p><em>TQt Designer</em> reads and writes <tt>.ui</tt> files, e.g. <tt>form.ui</tt>. The user interface compiler, <tt>uic</tt>, creates both a header file, e.g. <tt>form.h</tt>, and an implementation file, e.g. <tt>form.cpp</tt>, from the <tt>.ui</tt> file. The application code in <tt>main.cpp</tt><tt>#include</tt>s <tt>form.h</tt>. Typically <tt>main.cpp</tt> is used to instantiate the TQApplication object and start off the event loop.</p>
<p>While this approach is simple, it isn't sufficient for more complex dialogs. Complex dialogs tend to have quite a lot of logic attached to the form's widgets, more logic than can usually be expressed with predefined signals and slots. One way of handling this extra logic is to write a controller class in the application code that adds functionality to the form. This is possible because <tt>uic</tt> generated classes expose a form's controls and their signals to the public space. The big disadvantage of this method is that it's not exactly TQt-style. If you were not using <em>TQt Designer</em>, you would almost always add the logic to the form itself, where it belongs.</p>
<p>This is why the capability of adding custom slots and member variables to a form was added to <em>TQt Designer</em> early on. The big additional benefit with this approach is that you can use <em>TQt Designer</em> to connect signals to those custom slots, in the same elegant graphical way that is used to connect signals to predefined slots. The <tt>uic</tt> then adds an empty stub for each custom slot to the generated <tt>form.cpp</tt> implementation file.</p>
<p>The big question now is how to add custom implementation code to those custom slots. Adding code to the generated <tt>form.cpp</tt> is not an option, as this file gets recreated by the <tt>uic</tt> whenever the form changes -- and we don't want a combination of generated and handwritten code. There are two possible solutions, which we'll cover next.</p>
<p><em>TQt Designer</em> reads and writes <tt>.ui</tt> files, e.g. <tt>form.ui</tt>. The user interface compiler, <tt>tquic</tt>, creates both a header file, e.g. <tt>form.h</tt>, and an implementation file, e.g. <tt>form.cpp</tt>, from the <tt>.ui</tt> file. The application code in <tt>main.cpp</tt><tt>#include</tt>s <tt>form.h</tt>. Typically <tt>main.cpp</tt> is used to instantiate the TQApplication object and start off the event loop.</p>
<p>While this approach is simple, it isn't sufficient for more complex dialogs. Complex dialogs tend to have quite a lot of logic attached to the form's widgets, more logic than can usually be expressed with predefined signals and slots. One way of handling this extra logic is to write a controller class in the application code that adds functionality to the form. This is possible because <tt>tquic</tt> generated classes expose a form's controls and their signals to the public space. The big disadvantage of this method is that it's not exactly TQt-style. If you were not using <em>TQt Designer</em>, you would almost always add the logic to the form itself, where it belongs.</p>
<p>This is why the capability of adding custom slots and member variables to a form was added to <em>TQt Designer</em> early on. The big additional benefit with this approach is that you can use <em>TQt Designer</em> to connect signals to those custom slots, in the same elegant graphical way that is used to connect signals to predefined slots. The <tt>tquic</tt> then adds an empty stub for each custom slot to the generated <tt>form.cpp</tt> implementation file.</p>
<p>The big question now is how to add custom implementation code to those custom slots. Adding code to the generated <tt>form.cpp</tt> is not an option, as this file gets recreated by the <tt>tquic</tt> whenever the form changes -- and we don't want a combination of generated and handwritten code. There are two possible solutions, which we'll cover next.</p>
<p>Here the user wrote an additional class <b>FormImpl</b>, which is split into the header file <tt>formimpl.h</tt> and the implementation file <tt>formimpl.cpp</tt>. The header file includes the <tt>uic</tt> generated <tt>form.h</tt> and reimplements all the custom slots. This is possible because <tt>uic</tt> generated custom slots are virtual. In addition to implementing custom slots, this approach gives the user a way to do extra initialization work in the constructor of the subclass, and extra cleanups in the destructor.</p>
<p>Here the user wrote an additional class <b>FormImpl</b>, which is split into the header file <tt>formimpl.h</tt> and the implementation file <tt>formimpl.cpp</tt>. The header file includes the <tt>tquic</tt> generated <tt>form.h</tt> and reimplements all the custom slots. This is possible because <tt>tquic</tt> generated custom slots are virtual. In addition to implementing custom slots, this approach gives the user a way to do extra initialization work in the constructor of the subclass, and extra cleanups in the destructor.</p>
<p>Because of these benefits and its flexibility, this approach became the primary way of using <em>TQt Designer</em> in TQt 2.x.</p>
<p><b>Note:</b> To keep the namespace clean, most users did not follow the Form and FormImpl naming scheme shown in the figure, but instead named their <em>TQt Designer</em> forms FormBase and their subclasses Form. This made a lot of sense, because they always subclassed and were using those subclasses in application code.</p>
<p>Despite its flexibility and cleanness, the subclassing approach has some disadvantages:</p>
<ul><li><p>Subclassing is not natural and easy for everybody. Newcomers to object-oriented techniques may feel uneasy about being <em>forced</em> to subclass for such a simple and natural thing like the implementation of a custom slot.</p>
<li><p>Inheriting generated classes is an additional possible source of programming mistakes, especially if the number of reimplemented functions is high and the signatures change often during the design process. To make the development process smoother, <tt>uic</tt> generates empty stubs for custom slots rather than pure virtual functions. While this approach keeps the code compiling and running, programmers can find themselves in a situation where they miss a runtime warning message and lose time before they find a small spelling error in their subclass.</p>
<li><p>Inheriting generated classes is an additional possible source of programming mistakes, especially if the number of reimplemented functions is high and the signatures change often during the design process. To make the development process smoother, <tt>tquic</tt> generates empty stubs for custom slots rather than pure virtual functions. While this approach keeps the code compiling and running, programmers can find themselves in a situation where they miss a runtime warning message and lose time before they find a small spelling error in their subclass.</p>
<li><p>In larger projects with hundreds of forms, the additional subclasses can make a noticeable difference in terms of compilation speed and code size.</p>
</ul><p>There may be more disadvantages, but these were reason enough for us to investigate alternative solutions. For TQt 3.0, we came up with a new concept, the <em>ui.h extension</em>.</p>
<p>In addition to the <tt>.ui</tt> file, <tt>form.ui</tt>, <em>TQt Designer</em> reads and writes another associated file <tt>form.ui.h</tt>. This <tt>.ui.h</tt> file is an <em>ordinary C++ source file</em> that contains <em>implementations</em> of custom slots. The file gets included from the generated form implementation file <tt>form.cpp</tt> and thus can be totally ignored by other user code. The reason we use a <tt>.h</tt> extension for the <tt>.ui.h</tt> file even though it contains C++ code is because it is always <em>included</em>, and because it is easier to integrate into the build process with a <tt>.h</tt> extension.</p>
<p>The <tt>form.ui.h</tt> file has a special position among all other files. It is a <em>shared</em> source file that gets written and read by both the user and <em>TQt Designer</em>. As such it is an ordinary revision controlled source file and not generated by <tt>uic</tt>. <em>TQt Designer</em>'s responsibility is to keep the file in sync with the custom slot definitions of the associated form:</p>
<p>The <tt>form.ui.h</tt> file has a special position among all other files. It is a <em>shared</em> source file that gets written and read by both the user and <em>TQt Designer</em>. As such it is an ordinary revision controlled source file and not generated by <tt>tquic</tt>. <em>TQt Designer</em>'s responsibility is to keep the file in sync with the custom slot definitions of the associated form:</p>
<oltype=1><li><p>Whenever the users adds a new slots to the form, <em>TQt Designer</em> adds a stub to the <tt>.ui.h</tt> file.</p>
<li><p>Whenever the user changes a custom slot's signature, <em>TQt Designer</em> updates the corresponding implementation.</p>
<li><p>Whenever the user removes a custom slot, <em>TQt Designer</em> removes it from the <tt>.ui.h</tt> file.</p>
<p>We'll start with a general description of how to subclass a form and follow with a short example. Note that subclassing has some disadvantages compared with putting your code into a form directly; see <ahref="designer-manual-5.html#3">Extending the functionality of a form</a> in <ahref="designer-manual-5.html#the-designer-approach">The Designer Approach</a> chapter for details.</p>
<h4><aname="1-1"></a>Generating Source Code from <em>TQt Designer</em> .ui Files</h4>
<p><em>TQt Designer</em> reads and writes <tt>qmake</tt><!-- index .pro --><tt>.pro</tt> (project) files which are used to record the files used to build the application and from which Makefiles are generated. <em>TQt Designer</em> also reads and writes<!-- index .ui --><tt>.ui</tt> (user interface) files. These are XML files that record the widgets, layouts, source code and settings you've used for a form. Every<!-- index .ui --><tt>.ui</tt> file is converted by the <tt>uic</tt> (user interface compiler) into a C++<!-- index .h --><tt>.h</tt> file and a C++<!-- index .cpp --><tt>.cpp</tt> file. These C++ files are then read by <tt>tqmoc</tt> (meta object compiler), and finally compiled by your compiler into a working application.</p>
<p><em>TQt Designer</em> reads and writes <tt>qmake</tt><!-- index .pro --><tt>.pro</tt> (project) files which are used to record the files used to build the application and from which Makefiles are generated. <em>TQt Designer</em> also reads and writes<!-- index .ui --><tt>.ui</tt> (user interface) files. These are XML files that record the widgets, layouts, source code and settings you've used for a form. Every<!-- index .ui --><tt>.ui</tt> file is converted by the <tt>tquic</tt> (user interface compiler) into a C++<!-- index .h --><tt>.h</tt> file and a C++<!-- index .cpp --><tt>.cpp</tt> file. These C++ files are then read by <tt>tqmoc</tt> (meta object compiler), and finally compiled by your compiler into a working application.</p>
<!-- index Makefiles --><!-- index Projects!Adding Files --><!-- index Adding!Files to Projects --><p>If you create applications wholly within <em>TQt Designer</em> you only need to create a<!-- index main.cpp --><tt>main.cpp</tt>.</p>
<p>If you create the <tt>main.cpp</tt> file within <em>TQt Designer</em>, it will automatically be added to your project file by <em>TQt Designer</em>. If you create the <tt>main.cpp</tt> file outside of <em>TQt Designer</em> you must add it to the project file manually by adding the following line at the end of your project's<!-- index .pro --><tt>.pro</tt> file:</p>
<p>Incorporating custom widgets that have their own slots and properties is achieved in a similar way to adding signals. All the required information is in our custom widget's header file.</p>
<aname="creatingplugins"></a><h3><aname="2"></a>Creating Custom Widgets with Plugins</h3>
<!-- index Custom Widgets!Plugins --><!-- index Plugins!Implementing Custom Widgets --><p>This section will show you how to write a custom widget and how to embed the custom widget into a plugin. There are no restrictions or special considerations that must be taken into account when creating a widget that is destined to become a plugin. If you are an experienced TQt programmer you can safely skip the section on creating a custom widget and go directly to <ahref="designer-manual-7.html#2-2">Creating a Plugin</a>.</p>
<p>Be aware that if you use the plugin approach to custom widgets, the plugin needs to be available not only to <em>TQt Designer</em> but also to <tt>uic</tt> at compile-time.</p>
<p>Be aware that if you use the plugin approach to custom widgets, the plugin needs to be available not only to <em>TQt Designer</em> but also to <tt>tquic</tt> at compile-time.</p>
<h4><aname="2-1"></a>Creating a Custom Widget</h4>
<!-- index Creating Custom Widgets --><!-- index Widgets!Creating a Custom Widget --><!-- index Subclassing!Widgets --><p>A custom widget is often a specialization (subclass) of another widget or a combination of widgets working together or a blend of both these approaches. If you simply want a collection of widgets in a particular configuration it is easiest to create them, select them as a group, and copy and paste them as required within <em>TQt Designer</em>. Custom widgets are generally created when you need to add new functionality to existing widgets or groups of widgets.</p>
<!-- index Properties!Creating Custom Properties --><p>We have two recommendations that you should consider when creating a custom widget for a plugin:</p>
<p>If you wish to delete the add-in remove it from the toolbar then delete the<!-- index qmsdev.dll --><tt>qmsdev.dll</tt> file from the add-ins directory.</p>
<h4><aname="3-1"></a>Creating Makefiles without qmake</h4>
<!-- index Makefiles --><p>The <tt>qmake</tt> tool provided with TQt can create Makefiles appropriate to your platform based on<!-- index .pro --><tt>.pro</tt> project files. This section describes the dependencies involved in building a TQt application and gives a couple of simple example Makefiles. This section assumes that you have a good understanding of Makefiles.</p>
<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT --><p><em>TQt Designer</em> produces<!-- index .ui --><tt>.ui</tt> files which are used to generate<!-- index .h --><tt>.h</tt> and<!-- index .cpp --><tt>.cpp</tt> files for the compiler to compile. The<!-- index .ui --><tt>.ui</tt> files are processed by <tt>uic</tt>. Classes which inherit from <ahref="tqobject.html">TQObject</a>, e.g. those which use slots and signals, require an additional<!-- index .cpp --><tt>.cpp</tt> file to be generated. These files are generated by <tt>tqmoc</tt> and are named '<em>tqmoc_</em>file.cpp' where the original<!-- index .cpp --><tt>.cpp</tt> file is called 'file.cpp'. If your<!-- index .cpp --><tt>.cpp</tt> file contains the <tt>TQ_OBJECT</tt> macro an additional file 'file.moc' should be generated which must be <tt>#include</tt>d in the<!-- index .cpp --><tt>.cpp</tt>, normally at the end. This requires an extra dependency being created.</p>
<p>Processing<!-- index .ui --><tt>.ui</tt> files with <tt>uic</tt> is done <em>twice</em>:</p>
<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT --><p><em>TQt Designer</em> produces<!-- index .ui --><tt>.ui</tt> files which are used to generate<!-- index .h --><tt>.h</tt> and<!-- index .cpp --><tt>.cpp</tt> files for the compiler to compile. The<!-- index .ui --><tt>.ui</tt> files are processed by <tt>tquic</tt>. Classes which inherit from <ahref="tqobject.html">TQObject</a>, e.g. those which use slots and signals, require an additional<!-- index .cpp --><tt>.cpp</tt> file to be generated. These files are generated by <tt>tqmoc</tt> and are named '<em>tqmoc_</em>file.cpp' where the original<!-- index .cpp --><tt>.cpp</tt> file is called 'file.cpp'. If your<!-- index .cpp --><tt>.cpp</tt> file contains the <tt>TQ_OBJECT</tt> macro an additional file 'file.moc' should be generated which must be <tt>#include</tt>d in the<!-- index .cpp --><tt>.cpp</tt>, normally at the end. This requires an extra dependency being created.</p>
<p>Processing<!-- index .ui --><tt>.ui</tt> files with <tt>tquic</tt> is done <em>twice</em>:</p>
<pre>
uic myform.ui -o myform.h
uic myform.ui -i myform.h -o myform.cpp
tquic myform.ui -o myform.h
tquic myform.ui -i myform.h -o myform.cpp
</pre>
<p>The first execution creates the header file, the second creates the<!-- index .cpp --><tt>.cpp</tt> file. If you wish to subclass a form you can use <tt>uic</tt> to generate subclass skeletons:</p>
<p>The first execution creates the header file, the second creates the<!-- index .cpp --><tt>.cpp</tt> file. If you wish to subclass a form you can use <tt>tquic</tt> to generate subclass skeletons:</p>
<pre>
uic formbase.ui -o formbase.h
uic formbase.ui -i formbase.h -o formbase.cpp
uic -subdecl Form formbase.h formbase.ui -o form.h
uic -subimpl Form form.h formbase.ui -o form.cpp
tquic formbase.ui -o formbase.h
tquic formbase.ui -i formbase.h -o formbase.cpp
tquic -subdecl Form formbase.h formbase.ui -o form.h
tquic -subimpl Form form.h formbase.ui -o form.cpp
</pre>
<p>First we generate the header and implementation file for our base class. Then we generate the header and implementation skeletons for our subclass. Note that the use of <tt>uic</tt> to generate skeletons is not something that would be done in a Makefile, we mention it here because it can be useful for command line users. Note also that the command line for <tt>-subdecl</tt> and for <tt>-subimpl</tt> are subtly different.</p>
<p>First we generate the header and implementation file for our base class. Then we generate the header and implementation skeletons for our subclass. Note that the use of <tt>tquic</tt> to generate skeletons is not something that would be done in a Makefile, we mention it here because it can be useful for command line users. Note also that the command line for <tt>-subdecl</tt> and for <tt>-subimpl</tt> are subtly different.</p>
<p>For implementation files that contain classes which inherit from <ahref="tqobject.html">TQObject</a> we must create tqmoc files:</p>
<pre>
tqmoc myform.h -o tqmoc_myform.cpp
@ -147,12 +147,12 @@ myform.o: myform.cpp
g++ -o myform.o myform.cpp
myform.cpp: myform.h myform.ui
uic myform.ui -i myform.h -o myform.cpp
tquic myform.ui -i myform.h -o myform.cpp
myform.h: myform.ui
uic myform.ui -o myform.h
tquic myform.ui -o myform.h
</pre>
<p>Note that you may need to include the full path to the commands in your Makefile, and under Windows the filenames are<!-- index tqmoc.exe --><tt>tqmoc.exe</tt> and<!-- index uic.exe --><tt>uic.exe</tt>.</p>
<p>Note that you may need to include the full path to the commands in your Makefile, and under Windows the filenames are<!-- index tqmoc.exe --><tt>tqmoc.exe</tt> and<!-- index tquic.exe --><tt>tquic.exe</tt>.</p>
<p>In Unix/Linux environments the <tt>make</tt> command may be able to do more for us, so we should be able to use a simpler Makefile like this:</p>
<pre>
myapp: tqmoc_myform.o myform.o main.o
@ -165,10 +165,10 @@ tqmoc_%.cpp: %.h
tqmoc $^ -o $@
myform.cpp: myform.h myform.ui
uic myform.ui -i myform.h -o myform.cpp
tquic myform.ui -i myform.h -o myform.cpp
myform.h: myform.ui
uic myform.ui -o myform.h
tquic myform.ui -o myform.h
</pre>
<p>To see more sophisticated Makefiles simply generate them using <tt>qmake</tt> on any of your TQt projects or any of the examples supplied with TQt.</p>
<p>This variable specifies the .ui files (see <ahref="designer-manual.html">TQt Designer</a>) to be processed through <em>uic</em> before compiling. All dependencies, headers and source files required to build these .ui files will automatically be added to the project.</p>
<p>This variable specifies the .ui files (see <ahref="designer-manual.html">TQt Designer</a>) to be processed through <em>tquic</em> before compiling. All dependencies, headers and source files required to build these .ui files will automatically be added to the project.</p>
<p>This variable specifies the directory where all intermediate files from uic should be placed. This variable overrides both UI_SOURCES_DIR and UI_HEADERS_DIR.</p>
<p>This variable specifies the directory where all intermediate files from tquic should be placed. This variable overrides both UI_SOURCES_DIR and UI_HEADERS_DIR.</p>
<p>This variable specifies the directory where all implementation files (as generated by uic) should be placed.</p>
<p>This variable specifies the directory where all implementation files (as generated by tquic) should be placed.</p>
<p>For example:</p>
<pre>
unix:UI_SOURCES_DIR = ../myproject/ui/src
@ -500,10 +500,10 @@ app {
<h5><aname="4-2-93"></a>QMAKE_TARGET</h5>
<p>This variable contains the name of the project target. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<h5><aname="4-2-94"></a>QMAKE_UIC</h5>
<p>This variable contains the location of uic if it is not in the path. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<p>It can be used to specify arguments to uic as well, such as additional plugin paths. For example:</p>
<p>This variable contains the location of tquic if it is not in the path. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<p>It can be used to specify arguments to tquic as well, such as additional plugin paths. For example:</p>
<pre>
QMAKE_UIC = uic -L /path/to/plugin
QMAKE_UIC = tquic -L /path/to/plugin
</pre>
<h5><aname="4-2-95"></a>RC_FILE</h5>
<p>This variable contains the name of the resource file for the application. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
@ -518,7 +518,7 @@ app {
<h5><aname="4-2-100"></a>TARGET_x.y.z</h5>
<p>This variable specifies the target's extension with version number. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<h5><aname="4-2-101"></a>UICIMPLS</h5>
<p>This variable contains a list of the generated implementation files by UIC. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<p>This variable contains a list of the generated implementation files by TQUIC. The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<h5><aname="4-2-102"></a>UICOBJECTS</h5>
<p>This variable is generated from the UICIMPLS variable. The extension of each file will have been replaced by .o (Unix) or .obj (Win32). The value of this variable is typically handled by <em>qmake</em> or <ahref="qmake-manual-8.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p>
<string><b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++ output when it is compiled by uic.</p></string>
<string><b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++ output when it is compiled by tquic.</p></string>