summaryrefslogtreecommitdiffstats
path: root/doc/html/designer-manual-7.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/designer-manual-7.html')
-rw-r--r--doc/html/designer-manual-7.html18
1 files changed, 9 insertions, 9 deletions
diff --git a/doc/html/designer-manual-7.html b/doc/html/designer-manual-7.html
index 8471e5eb..5f28e2d8 100644
--- a/doc/html/designer-manual-7.html
+++ b/doc/html/designer-manual-7.html
@@ -68,8 +68,8 @@ body { background: #ffffff; color: black; }
<a href="qpushbutton.html">TQPushButton</a> *rewind = new <a href="qpushbutton.html">TQPushButton</a>( TQPixmap( rewind_xpm ), 0, this, "vcr_rewind" );
layout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( rewind );
</pre>
- <p>We create a <a href="qhboxlayout.html">TQHBoxLayout</a> in which we'll place the buttons. We've only shown the rewind button in the code above since all the others are identical except for the names of the buttons, pixmaps and signals. For each of the buttons we retquire we call the <a href="qpushbutton.html">TQPushButton</a> constructor passing it the appropriate embedded pixmap. We then add it to the layout. Finally we connect the button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate <em>signal</em>. Since the<!-- index clicked() --> <tt>clicked()</tt> signals aren't specific to our widget we want to emit signals that reflect the widget's use. The <tt>rewind()</tt>, <tt>play()</tt>, etc. signals are meaningful in the context of our widget so we propagate each button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate widget-specific signal.</p>
-<!-- index Forms!Creating Test Harnesses --><p>The implementation is complete, but to make sure that our widget compiles and runs we'll create a tiny test harness. The test harness will retquire two files, a<!-- index .pro --> <tt>.pro</tt> project file and a<!-- index main.cpp --> <tt>main.cpp</tt>. The <tt>qt/tools/designer/examples/vcr/vcr.pro</tt> project file:</p>
+ <p>We create a <a href="qhboxlayout.html">TQHBoxLayout</a> in which we'll place the buttons. We've only shown the rewind button in the code above since all the others are identical except for the names of the buttons, pixmaps and signals. For each of the buttons we require we call the <a href="qpushbutton.html">TQPushButton</a> constructor passing it the appropriate embedded pixmap. We then add it to the layout. Finally we connect the button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate <em>signal</em>. Since the<!-- index clicked() --> <tt>clicked()</tt> signals aren't specific to our widget we want to emit signals that reflect the widget's use. The <tt>rewind()</tt>, <tt>play()</tt>, etc. signals are meaningful in the context of our widget so we propagate each button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate widget-specific signal.</p>
+<!-- index Forms!Creating Test Harnesses --><p>The implementation is complete, but to make sure that our widget compiles and runs we'll create a tiny test harness. The test harness will require two files, a<!-- index .pro --> <tt>.pro</tt> project file and a<!-- index main.cpp --> <tt>main.cpp</tt>. The <tt>qt/tools/designer/examples/vcr/vcr.pro</tt> project file:</p>
<pre>TEMPLATE = app
LANGUAGE = C++
TARGET = vcr
@@ -104,12 +104,12 @@ DBFILE = vcr.db
</ol><p>The remaining items to be completed will depend on the characteristics of the widget you've created. If, for example, your widget can be used to contain other widgets you'd check the Container Widget checkbox. In the case of our Vcr example the only items we need to add are its signals.</p>
<p>Click the Signals tab. Click the <b>New Signal</b> button and type in the signal name 'rewind()'. Click <b>New Signal</b> again and this time type in 'play()'. Add the 'next()' and 'stop()' signals in the same way.</p>
<p>Since our example hasn't any slots or properties we've finished and can click <b>Close</b>. A new icon will appear in <em>TQt Designer</em>'s toolbars which represents the new widget. If you create a new form you can add Vcr widgets and connect the Vcr's signals to your slots.</p>
-<p>Incorporating custom widgets that have their own slots and properties is achieved in a similar way to adding signals. All the retquired information is in our custom widget's header 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>
<a name="creatingplugins"></a><h3><a name="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 <a href="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>
<h4><a name="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 retquired 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 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>
<ol type=1><li><p>Using TQt's property system will provide <em>TQt Designer</em> users with a direct means of configuring the widget through the property editor. (See the <a href="http://doc.trolltech.com/properties.html">TQt Properties</a> documentation.)</p>
<li><p>Consider making your widget's public 'set' functions into public slots so that you can perform signal-slot connections with the widget in <em>TQt Designer</em>.</p>
@@ -128,7 +128,7 @@ DBFILE = vcr.db
</pre>
<p>Our widget will be derived from <a href="qwidget.html">TQWidget</a> so we include the <tt>qwidget.h</tt> header file. We also forward declare the two classes that our widget will be built from.</p>
<pre></pre>
-<!-- index Macros!Q_OBJECT --><!-- index Q_OBJECT --><!-- index Macros!Q_ENUMS --><!-- index Q_ENUMS --> <p>We include the <tt>Q_OBJECT</tt> macro since this is retquired for classes that declare signals or slots. The <tt>Q_ENUMS</tt> declaration is used to register the Mode enumeration. Our widget has two properties, mode, to store whether the user should select a File or a Directory and fileName which stores the file or directory they chose.</p>
+<!-- index Macros!Q_OBJECT --><!-- index Q_OBJECT --><!-- index Macros!Q_ENUMS --><!-- index Q_ENUMS --> <p>We include the <tt>Q_OBJECT</tt> macro since this is required for classes that declare signals or slots. The <tt>Q_ENUMS</tt> declaration is used to register the Mode enumeration. Our widget has two properties, mode, to store whether the user should select a File or a Directory and fileName which stores the file or directory they chose.</p>
<pre> class QT_WIDGET_PLUGIN_EXPORT FileChooser : public <a href="qwidget.html">TQWidget</a>
{
Q_OBJECT
@@ -222,7 +222,7 @@ DBFILE = vcr.db
<p>When <tt>chooseFile()</tt> is called it presents the user with a file or directory dialog depending on the mode. If the user chooses a file or directory the <a href="qlineedit.html">TQLineEdit</a> is updated with the chosen file or directory and the <tt>fileNameChanged()</tt> signal is emitted.</p>
<p>Although these two files complete the implementation of the FileChooser widget it is good practice to write a test harness to check that the widget behaves as expected before attempting to put it into a plugin.</p>
<h5><a name="2-1-3"></a>Testing the Implementation</h5>
-<!-- index main.cpp --><!-- index Forms!Creating Test Harnesses --><p>We present a rudimentary test harness which will allow us to run our custom widget. The test harness retquires two files, a <tt>main.cpp</tt> to contain the FileChooser, and a <tt>.pro</tt> file to create the Makefile from. Here is <tt>qt/tools/designer/examples/filechooser/widget/main.cpp</tt>:</p>
+<!-- index main.cpp --><!-- index Forms!Creating Test Harnesses --><p>We present a rudimentary test harness which will allow us to run our custom widget. The test harness requires two files, a <tt>main.cpp</tt> to contain the FileChooser, and a <tt>.pro</tt> file to create the Makefile from. Here is <tt>qt/tools/designer/examples/filechooser/widget/main.cpp</tt>:</p>
<pre> #include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
#include "filechooser.h"
@@ -245,13 +245,13 @@ CONFIG += qt warn_on release
DBFILE = filechooser.db
DEFINES += FILECHOOSER_IS_WIDGET
</pre>
-<p>We can create the makefile using <tt>qmake</tt>: <tt>qmake -o Makefile filechooser.pro</tt>, then we can make and run the harness to test our new widget. Once we're satisfied that the custom widget is robust and has the behaviour we retquire we can embed it into a plugin.</p>
+<p>We can create the makefile using <tt>qmake</tt>: <tt>qmake -o Makefile filechooser.pro</tt>, then we can make and run the harness to test our new widget. Once we're satisfied that the custom widget is robust and has the behaviour we require we can embed it into a plugin.</p>
<h4><a name="2-2"></a>Creating a Plugin</h4>
<!-- index Creating Plugins --><!-- index Plugins!Creating a Plugin --><!-- index Component!Plugins --><p>TQt Plugins can be used to provide self-contained software components for TQt applications. TQt currently supports the creation of five kinds of plugins: codecs, image formats, database drivers, styles and custom widgets. In this section we will explain how to convert our filechooser custom widget into a <em>TQt Designer</em> custom widget plugin.</p>
<p>A <em>TQt Designer</em> custom widget plugin is always derived from <a href="qwidgetplugin.html">TQWidgetPlugin</a>. The amout of code that needs to be written is minimal.</p>
-<p>To make your own plugin it is probably easiest to start by copying our example<!-- index plugin.h --> <tt>plugin.h</tt> and<!-- index plugin.cpp --> <tt>plugin.cpp</tt> files and changing 'CustomWidgetPlugin' to the name you wish to use for your widget plugin implementation class. Below we provide an introduction to the header file although it needs no changes beyond class renaming. The implementation file retquires simple changes, mostly more class renaming; we will review each function in turn and explain what you need to do.</p>
+<p>To make your own plugin it is probably easiest to start by copying our example<!-- index plugin.h --> <tt>plugin.h</tt> and<!-- index plugin.cpp --> <tt>plugin.cpp</tt> files and changing 'CustomWidgetPlugin' to the name you wish to use for your widget plugin implementation class. Below we provide an introduction to the header file although it needs no changes beyond class renaming. The implementation file requires simple changes, mostly more class renaming; we will review each function in turn and explain what you need to do.</p>
<h5><a name="2-2-1"></a>The <b>CustomWidgetPlugin</b> Implementation</h5>
-<p>We have called our header file<!-- index plugin.h --> <tt>plugin.h</tt> and we've called our plugin class <b>CustomWidgetPlugin</b> since we will be using our plugin class to wrap our custom widgets. We present the entire header file to give you an impression of the scope of the implementation retquired. Most of the functions retquire just a few lines of code.</p>
+<p>We have called our header file<!-- index plugin.h --> <tt>plugin.h</tt> and we've called our plugin class <b>CustomWidgetPlugin</b> since we will be using our plugin class to wrap our custom widgets. We present the entire header file to give you an impression of the scope of the implementation required. Most of the functions require just a few lines of code.</p>
<pre> #include &lt;<a href="qwidgetplugin-h.html">qwidgetplugin.h</a>&gt;
class CustomWidgetPlugin : public <a href="qwidgetplugin.html">TQWidgetPlugin</a>