diff options
Diffstat (limited to 'doc/html/designer-manual-6.html')
-rw-r--r-- | doc/html/designer-manual-6.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/html/designer-manual-6.html b/doc/html/designer-manual-6.html index 9c9845df8..e6825b8ef 100644 --- a/doc/html/designer-manual-6.html +++ b/doc/html/designer-manual-6.html @@ -95,7 +95,7 @@ int main( int argc, char *argv[] ) } </pre> <p>Note that we're including <tt>creditformbase.h</tt> and instantiating a CreditFormBase object; once we've written our subclass we'll replace the header with our subclass, <tt>creditform.h</tt>, and instantiate a CreditForm.</p> -<p>We can now generate the application with <tt>qmake</tt>, e.g. <tt>qmake -o Makefile credit.pro</tt>, make it and run it. The form should run fine, but doesn't yet have the behaviour we retquire.</p> +<p>We can now generate the application with <tt>qmake</tt>, e.g. <tt>qmake -o Makefile credit.pro</tt>, make it and run it. The form should run fine, but doesn't yet have the behaviour we require.</p> <h5><a name="1-3-3"></a>Creating the Subclass</h5> <p>We need to create a header and an implementation file for our subclass. The code for our subclass is minimal. The header file is <tt>qt/tools/designer/examples/credit/creditform.h</tt>:</p> <pre> #include "creditformbase.h" @@ -174,7 +174,7 @@ FORMS = mainform.ui LANGUAGE = C++ INCLUDEPATH += $(QTDIR)/tools/designer/uilib </pre> -<p>We do <em>not</em> include the <tt>creditformbase.ui</tt> file since this file will be read at runtime, as we'll see shortly. We must include the <tt>tqui</tt> library since the functionality we retquire is not part of the standard TQt library.</p> +<p>We do <em>not</em> include the <tt>creditformbase.ui</tt> file since this file will be read at runtime, as we'll see shortly. We must include the <tt>tqui</tt> library since the functionality we require is not part of the standard TQt library.</p> <h4><a name="2-2"></a>Creating main.cpp</h4> <p>The<!-- index main.cpp --> <tt>main.cpp</tt> is quite standard. It will invoke the form we're going to create in <em>TQt Designer</em> as its main form. This form will then load and execute the dynamic dialog.</p> <pre> #include <<a href="qapplication-h.html">qapplication.h</a>> @@ -217,7 +217,7 @@ INCLUDEPATH += $(QTDIR)/tools/designer/uilib delete creditForm; } </pre> - <p>The<!-- index create() --> <tt>create()</tt> function is a static <a href="qwidgetfactory.html">TQWidgetFactory</a> function. It loads the specified<!-- index .ui --> <tt>.ui</tt> file and returns a pointer to the toplevel <a href="qwidget.html">TQWidget</a> created from the<!-- index .ui --> <tt>.ui</tt> file. We have cast the pointer to <a href="qdialog.html">TQDialog</a> since we know that the <tt>creditformbase.ui</tt> file defines a <a href="qdialog.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 retquired.</p> + <p>The<!-- index create() --> <tt>create()</tt> function is a static <a href="qwidgetfactory.html">TQWidgetFactory</a> function. It loads the specified<!-- index .ui --> <tt>.ui</tt> file and returns a pointer to the toplevel <a href="qwidget.html">TQWidget</a> created from the<!-- index .ui --> <tt>.ui</tt> file. We have cast the pointer to <a href="qdialog.html">TQDialog</a> since we know that the <tt>creditformbase.ui</tt> file defines a <a href="qdialog.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="qpushbutton.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="qobjectlist.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/qobject.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="qobject.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> @@ -260,7 +260,7 @@ private: }; </pre> <!-- index Macros!Q_OBJECT --><!-- index Q_OBJECT!Macros --><p>Our class must be a <a href="qobject.html">TQObject</a> subclass and because we're using signals and slots it must include the <tt>Q_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="qdialog.html">TQDialog</a> pointer.</p> -<p>The implementation retquires the header files of the classes it uses:</p> +<p>The implementation requires the header files of the classes it uses:</p> <pre> #include <<a href="qradiobutton-h.html">qradiobutton.h</a>> #include <<a href="qspinbox-h.html">qspinbox.h</a>> #include "receiver.h" |