summaryrefslogtreecommitdiffstats
path: root/doc/html/designer-manual-6.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/designer-manual-6.html')
-rw-r--r--doc/html/designer-manual-6.html18
1 files changed, 9 insertions, 9 deletions
diff --git a/doc/html/designer-manual-6.html b/doc/html/designer-manual-6.html
index b21aa1652..50e109a61 100644
--- a/doc/html/designer-manual-6.html
+++ b/doc/html/designer-manual-6.html
@@ -210,7 +210,7 @@ INCLUDEPATH += $(TQTDIR)/tools/designer/uilib
if ( creditForm-&gt;<a href="ntqdialog.html#exec">exec</a>() ) {
// The user accepted, act accordingly
- <a href="ntqspinbox.html">TQSpinBox</a> *amount = (TQSpinBox *) creditForm-&gt;<a href="ntqobject.html#child">child</a>( "amountSpinBox", "TQSpinBox" );
+ <a href="ntqspinbox.html">TQSpinBox</a> *amount = (TQSpinBox *) creditForm-&gt;<a href="tqobject.html#child">child</a>( "amountSpinBox", "TQSpinBox" );
if ( amount )
ratingTextLabel-&gt;setText( amount-&gt;<a href="ntqspinbox.html#text">text</a>() );
}
@@ -218,10 +218,10 @@ INCLUDEPATH += $(TQTDIR)/tools/designer/uilib
}
</pre>
<p>The<!-- index create() --> <tt>create()</tt> function is a static <a href="ntqwidgetfactory.html">TQWidgetFactory</a> function. It loads the specified<!-- index .ui --> <tt>.ui</tt> file and returns a pointer to the toplevel <a href="ntqwidget.html">TQWidget</a> created from the<!-- index .ui --> <tt>.ui</tt> file. We have cast the pointer to <a href="ntqdialog.html">TQDialog</a> since we know that the <tt>creditformbase.ui</tt> file defines a <a href="ntqdialog.html">TQDialog</a>. After creating the dialog we<!-- index exec() --> <tt>exec()</tt> it. If the user clicked <b>OK</b> the dialog returns Accepted and we enter the body of the <tt>if</tt> statement. We want to know the amount of credit that the user selected. We call the<!-- index child() --> <tt>child()</tt> function on the dialog passing it the name of the widget we're interested in. The<!-- index child() --> <tt>child()</tt> function returns a pointer to the widget with the name we passed, or returns 0 if no widget of that name was found. In the example we call<!-- index child() --> <tt>child()</tt> to get a pointer to the 'amountSpinBox'. If the pointer we get back is not 0 we set the rating text to the amount in the dialog's spin box. At the end we delete the dynamic dialog. Deleting the dialog ensures that we free up its resources as soon as it is no longer required.</p>
-<p>We used the<!-- index child() --> <tt>child()</tt> to gain access to a widget within the dynamic dialog, passing it the name of the widget we were interested in. In some situations we might not know what a widget is called. We can access the first widget of a specified class by calling<!-- index child() --> <tt>child()</tt> with a null widget name and a classname, e.g. <tt>child(0,"TQPushButton")</tt>. This will return a pointer to the first <a href="ntqpushbutton.html">TQPushButton</a> it finds (or 0 if there isn't one). If you want pointers to all the widgets of a given class you can call the<!-- index TQObject::queryList() --> <tt>TQObject::queryList()</tt> function, passing it the name of the class. It returns a <a href="ntqobjectlist.html">TQObjectList</a> pointer which points to every object in the dialog that is derived from the given class. See the online <a href="http://doc.trolltech.com/ntqobject.html">TQObject</a> documentation for further details.</p>
+<p>We used the<!-- index child() --> <tt>child()</tt> to gain access to a widget within the dynamic dialog, passing it the name of the widget we were interested in. In some situations we might not know what a widget is called. We can access the first widget of a specified class by calling<!-- index child() --> <tt>child()</tt> with a null widget name and a classname, e.g. <tt>child(0,"TQPushButton")</tt>. This will return a pointer to the first <a href="ntqpushbutton.html">TQPushButton</a> it finds (or 0 if there isn't one). If you want pointers to all the widgets of a given class you can call the<!-- index TQObject::queryList() --> <tt>TQObject::queryList()</tt> function, passing it the name of the class. It returns a <a href="tqobjectlist.html">TQObjectList</a> pointer which points to every object in the dialog that is derived from the given class. See the online <a href="http://doc.trolltech.com/tqobject.html">TQObject</a> documentation for further details.</p>
<h5><a name="2-3-3"></a>Implementing Slots for Dynamic Dialogs</h5>
-<!-- index Signals and Slots!Dynamic Dialogs --><!-- index Dynamic Dialogs --><p>There is one outstanding issue that we haven't addressed: the dynamic dialog does not have the behaviour of the original credit dialog because we have not implemented the <tt>setAmount()</tt> slot. We can implement slots for dynamic dialogs by creating a <a href="ntqobject.html">TQObject</a> subclass. We then create an instance of this subclass and pass a pointer to it to the<!-- index TQWidgetFactory::create() --> <tt>TQWidgetFactory::create()</tt> function which will connect the dynamic dialog's signals to the slots implemented in our subclass.</p>
-<p>We need to create a <a href="ntqobject.html">TQObject</a> subclass and change our <tt>creditDialog()</tt> to create an instance of our subclass that can be passed to the<!-- index TQWidgetFactory::create() --> <tt>TQWidgetFactory::create()</tt> function. Here is the modified <tt>creditDialog()</tt> function from the <tt>qt/tools/designer/examples/receiver2/mainform.ui.h</tt> file that contains the code for <tt>mainform.ui</tt>'s slots:</p>
+<!-- index Signals and Slots!Dynamic Dialogs --><!-- index Dynamic Dialogs --><p>There is one outstanding issue that we haven't addressed: the dynamic dialog does not have the behaviour of the original credit dialog because we have not implemented the <tt>setAmount()</tt> slot. We can implement slots for dynamic dialogs by creating a <a href="tqobject.html">TQObject</a> subclass. We then create an instance of this subclass and pass a pointer to it to the<!-- index TQWidgetFactory::create() --> <tt>TQWidgetFactory::create()</tt> function which will connect the dynamic dialog's signals to the slots implemented in our subclass.</p>
+<p>We need to create a <a href="tqobject.html">TQObject</a> subclass and change our <tt>creditDialog()</tt> to create an instance of our subclass that can be passed to the<!-- index TQWidgetFactory::create() --> <tt>TQWidgetFactory::create()</tt> function. Here is the modified <tt>creditDialog()</tt> function from the <tt>qt/tools/designer/examples/receiver2/mainform.ui.h</tt> file that contains the code for <tt>mainform.ui</tt>'s slots:</p>
<pre> void MainForm::creditDialog()
{
Receiver *receiver = new Receiver;
@@ -233,7 +233,7 @@ INCLUDEPATH += $(TQTDIR)/tools/designer/uilib
if ( creditForm-&gt;<a href="ntqdialog.html#exec">exec</a>() ) {
// The user accepted, act accordingly
- <a href="ntqspinbox.html">TQSpinBox</a> *amount = (TQSpinBox *) creditForm-&gt;<a href="ntqobject.html#child">child</a>( "amountSpinBox", "TQSpinBox" );
+ <a href="ntqspinbox.html">TQSpinBox</a> *amount = (TQSpinBox *) creditForm-&gt;<a href="tqobject.html#child">child</a>( "amountSpinBox", "TQSpinBox" );
if ( amount )
ratingTextLabel-&gt;setText( amount-&gt;<a href="ntqspinbox.html#text">text</a>() );
}
@@ -245,10 +245,10 @@ INCLUDEPATH += $(TQTDIR)/tools/designer/uilib
<p>We create a new instance of our 'Receiver' subclass. (We'll write the code for this class shortly.) We then create the <a href="ntqdialog.html">TQDialog</a> using<!-- index TQWidgetFactory::create() --> <tt>TQWidgetFactory::create()</tt>. This call differs from our previous example because we pass in the subclass object so that the<!-- index create() --> <tt>create()</tt> function can set up the signals/slots connections automatically for us. Since our slot must access the widgets in the dynamic form we pass a pointer to the form to the receiver object through our <tt>setParent()</tt> function. The remainder of the function is the same as before except that we delete our receiver object.</p>
<p>Since we are using the 'Receiver' subclass in our main form we must include its header file. In <em>Object Explorer</em>'s Members tab, right click Includes (in Implmentation), then click <b>New</b>. Type in '<tt>receiver.h</tt>', then press <b>Enter</b>.</p>
<!-- index Dynamic Dialogs --><p>We'll now look at the implementation of our 'Receiver' subclass. The code is taken from <tt>qt/tools/designer/examples/receiver2/receiver.h</tt> and the corresponding <tt>receiver.cpp</tt> file. We'll start with the header file.</p>
-<pre>#include &lt;<a href="qobject-h.html">ntqobject.h</a>&gt;
+<pre>#include &lt;<a href="tqobject-h.html">tqobject.h</a>&gt;
#include &lt;<a href="qdialog-h.html">ntqdialog.h</a>&gt;
-class Receiver : public <a href="ntqobject.html">TQObject</a>
+class Receiver : public <a href="tqobject.html">TQObject</a>
{
TQ_OBJECT
public:
@@ -259,7 +259,7 @@ private:
<a href="ntqdialog.html">TQDialog</a> *p;
};
</pre>
-<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT!Macros --><p>Our class must be a <a href="ntqobject.html">TQObject</a> subclass and because we're using signals and slots it must include the <tt>TQ_OBJECT</tt> macro. We declare a function and the <tt>setAmount()</tt> slot that we wish to implement as well as a private <a href="ntqdialog.html">TQDialog</a> pointer.</p>
+<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT!Macros --><p>Our class must be a <a href="tqobject.html">TQObject</a> subclass and because we're using signals and slots it must include the <tt>TQ_OBJECT</tt> macro. We declare a function and the <tt>setAmount()</tt> slot that we wish to implement as well as a private <a href="ntqdialog.html">TQDialog</a> pointer.</p>
<p>The implementation requires the header files of the classes it uses:</p>
<pre> #include &lt;<a href="qradiobutton-h.html">ntqradiobutton.h</a>&gt;
#include &lt;<a href="qspinbox-h.html">ntqspinbox.h</a>&gt;
@@ -297,7 +297,7 @@ private:
<blockquote>
<p align="center"><b> Compiling vs Dynamically Loading Dialogs</b></p>
<!-- index Dynamic Dialogs!Compared with Compiling --><!-- index Dynamic Dialogs!Subclassing --><!-- index Subclassing!Dynamic Dialogs --><p>The differences between using a 'compiled in'<!-- index .ui --> <tt>.ui</tt> file and a dynamically loaded<!-- index .ui --> <tt>.ui</tt> file are these:</p>
-<ul><li><p>Dynamic dialogs cannot have any C++ code in the<!-- index .ui --> <tt>.ui</tt> file; any custom slots must be implemented via a <a href="ntqobject.html">TQObject</a> subclass. Compiled dialogs can contain code either in the<!-- index .ui --> <tt>.ui</tt> file or in a subclass.</p>
+<ul><li><p>Dynamic dialogs cannot have any C++ code in the<!-- index .ui --> <tt>.ui</tt> file; any custom slots must be implemented via a <a href="tqobject.html">TQObject</a> subclass. Compiled dialogs can contain code either in the<!-- index .ui --> <tt>.ui</tt> file or in a subclass.</p>
<li><p>Dynamic dialogs will load slower because the<!-- index .ui --> <tt>.ui</tt> file must be read and a <a href="ntqwidget.html">TQWidget</a> instance instantiated based on the<!-- index .ui --> <tt>.ui</tt> file's parse tree. Compiled code will load much faster because no file reading or parsing is necessary. Note that the user may not notice any difference in speed since the difference may be mere fractions of a second.</p>
<li><p>Dynamic dialogs allow you to change the<!-- index .ui --> <tt>.ui</tt> file independently of the code so long as none of the changes impact the code. This means that you can change the appearance of the form, e.g. move widgets and lay them out differently. If you want to change a compiled dialog you must change the<!-- index .ui --> <tt>.ui</tt> file and recompile. If you are building an application and want your customers to be able to customize aspects of the user interface you can give them a copy of <em>TQt Designer</em> (if your license permits this) and use dynamic dialogs.</p>
</ul></blockquote>