From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/tutorial1-07.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'doc/html/tutorial1-07.html') diff --git a/doc/html/tutorial1-07.html b/doc/html/tutorial1-07.html index a54ef7803..706ba9ee7 100644 --- a/doc/html/tutorial1-07.html +++ b/doc/html/tutorial1-07.html @@ -57,27 +57,27 @@ Chapter 6; only the changes are noted here. happens to be included more than once. If you don't use it already, it is a very good habit to develop. The #ifndef should enclose all of the header file. -

    #include <qvbox.h>
+

    #include <ntqvbox.h>
 
-

qvbox.h is included. LCDRange inherits TQVBox, and the header file +

ntqvbox.h is included. LCDRange inherits TQVBox, and the header file of a parent class must always be included. We cheated a bit in the -previous chapters, and we let qwidget.h be included indirectly via -other header files such as qpushbutton.h. +previous chapters, and we let ntqwidget.h be included indirectly via +other header files such as ntqpushbutton.h.

    class TQSlider;
 

This is another classic trick, but one that's much less used often. Because -we don't need TQSlider in the interface of the class, only in the +we don't need TQSlider in the interface of the class, only in the implementation, we use a forward declaration of the class in the header file and include the header file for TQSlider in the .cpp file.

This makes the compilation of big projects much faster, because when a header file has changed, fewer files need to be recompiled. It can often speed up big compilations by a factor of two or more. -

    class LCDRange : public TQVBox
+

    class LCDRange : public TQVBox
     {
         Q_OBJECT
     public:
-        LCDRange( TQWidget *parent=0, const char *name=0 );
+        LCDRange( TQWidget *parent=0, const char *name=0 );
 

Note the Q_OBJECT. This macro must be included in all classes that contain signals and/or slots. If you are curious, it defines the @@ -110,9 +110,9 @@ signal you'll see called somethingChanged().

This file is mainly lifted from t6/main.cpp, and only the changes are noted here. -

        connect( slider, SIGNAL(valueChanged(int)),
-                 lcd, SLOT(display(int)) );
-        connect( slider, SIGNAL(valueChanged(int)),
+

        connect( slider, SIGNAL(valueChanged(int)),
+                 lcd, SLOT(display(int)) );
+        connect( slider, SIGNAL(valueChanged(int)),
                  SIGNAL(valueChanged(int)) );
 

This code is from the LCDRange constructor. @@ -125,23 +125,23 @@ the first is emitted, the second signal is also emitted.

Let's look at what happens when the user operates the slider. The slider sees that its value has changed and emits the valueChanged() signal. That signal is connected both to the display() slot of the -TQLCDNumber and to the valueChanged() signal of the LCDRange. +TQLCDNumber and to the valueChanged() signal of the LCDRange.

Thus, when the signal is emitted, LCDRange emits its own -valueChanged() signal. In addition, TQLCDNumber::display() is called +valueChanged() signal. In addition, TQLCDNumber::display() is called and shows the new number.

Note that you're not guaranteed any particular order of execution - LCDRange::valueChanged() may be emitted before or after TQLCDNumber::display()and is entirely arbitrary.

    int LCDRange::value() const
     {
-        return slider->value();
+        return slider->value();
     }
 

The implementation of value() is straightforward; it simply returns the slider's value.

    void LCDRange::setValue( int value )
     {
-        slider->setValue( value );
+        slider->setValue( value );
     }
 

The implementation of setValue() is equally straightforward. Note @@ -158,7 +158,7 @@ outside its legal range. for( int c = 0 ; c < 4 ; c++ ) { LCDRange* lr = new LCDRange( grid ); if ( previous ) - connect( lr, SIGNAL(valueChanged(int)), + connect( lr, SIGNAL(valueChanged(int)), previous, SLOT(setValue(int)) ); previous = lr; } -- cgit v1.2.1