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-05.html | 88 +++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'doc/html/tutorial1-05.html') diff --git a/doc/html/tutorial1-05.html b/doc/html/tutorial1-05.html index 23944871..772569d0 100644 --- a/doc/html/tutorial1-05.html +++ b/doc/html/tutorial1-05.html @@ -41,46 +41,46 @@ by using signals and slots, and how to handle resize events. ** ****************************************************************/ -#include <qapplication.h> -#include <qpushbutton.h> -#include <qslider.h> -#include <qlcdnumber.h> -#include <qfont.h> +#include <ntqapplication.h> +#include <ntqpushbutton.h> +#include <ntqslider.h> +#include <ntqlcdnumber.h> +#include <ntqfont.h> -#include <qvbox.h> +#include <ntqvbox.h> -class MyWidget : public TQVBox +class MyWidget : public TQVBox { public: - MyWidget( TQWidget *parent=0, const char *name=0 ); + MyWidget( TQWidget *parent=0, const char *name=0 ); }; -MyWidget::MyWidget( TQWidget *parent, const char *name ) - : TQVBox( parent, name ) +MyWidget::MyWidget( TQWidget *parent, const char *name ) + : TQVBox( parent, name ) { - TQPushButton *quit = new TQPushButton( "Quit", this, "quit" ); - quit->setFont( TQFont( "Times", 18, TQFont::Bold ) ); + TQPushButton *quit = new TQPushButton( "Quit", this, "quit" ); + quit->setFont( TQFont( "Times", 18, TQFont::Bold ) ); - connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); + connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); - TQLCDNumber *lcd = new TQLCDNumber( 2, this, "lcd" ); + TQLCDNumber *lcd = new TQLCDNumber( 2, this, "lcd" ); - TQSlider * slider = new TQSlider( Horizontal, this, "slider" ); - slider->setRange( 0, 99 ); - slider->setValue( 0 ); + TQSlider * slider = new TQSlider( Horizontal, this, "slider" ); + slider->setRange( 0, 99 ); + slider->setValue( 0 ); - connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) ); + connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) ); } int main( int argc, char **argv ) { - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); MyWidget w; - a.setMainWidget( &w ); - w.show(); - return a.exec(); + a.setMainWidget( &w ); + w.show(); + return a.exec(); } @@ -88,45 +88,45 @@ int main( int argc, char **argv )

Line-by-line Walkthrough

-

    #include <qapplication.h>
-    #include <qpushbutton.h>
-    #include <qslider.h>
-    #include <qlcdnumber.h>
-    #include <qfont.h>
+

    #include <ntqapplication.h>
+    #include <ntqpushbutton.h>
+    #include <ntqslider.h>
+    #include <ntqlcdnumber.h>
+    #include <ntqfont.h>
 
-    #include <qvbox.h>
+    #include <ntqvbox.h>
 
-

Three new include files are shown here. qslider.h and qlcdnumber.h are there -because we use two new widgets, TQSlider and TQLCDNumber. qvbox.h is +

Three new include files are shown here. ntqslider.h and ntqlcdnumber.h are there +because we use two new widgets, TQSlider and TQLCDNumber. ntqvbox.h is here because we use TQt's automatic layout support. -

    class MyWidget : public TQVBox
+

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

-

    MyWidget::MyWidget( TQWidget *parent, const char *name )
-            : TQVBox( parent, name )
+
    MyWidget::MyWidget( TQWidget *parent, const char *name )
+            : TQVBox( parent, name )
     {
 
-

MyWidget is now derived from TQVBox instead of TQWidget. That way we use +

MyWidget is now derived from TQVBox instead of TQWidget. That way we use the layout of the TQVBox (which places all of its children vertically inside itself). Resizes are now handled automatically by the TQVBox and therefore by MyWidget, too. -

        TQLCDNumber *lcd  = new TQLCDNumber( 2, this, "lcd" );
+

        TQLCDNumber *lcd  = new TQLCDNumber( 2, this, "lcd" );
 

lcd is a TQLCDNumber, a widget that displays numbers in an LCD-like fashion. This instance is set up to display two digits and to be a child of this. It is named "lcd". -

        TQSlider * slider = new TQSlider( Horizontal, this, "slider" );
-        slider->setRange( 0, 99 );
-        slider->setValue( 0 );
+

        TQSlider * slider = new TQSlider( Horizontal, this, "slider" );
+        slider->setRange( 0, 99 );
+        slider->setValue( 0 );
 
-

TQSlider is a classical slider; the user can use the widget to drag +

TQSlider is a classical slider; the user can use the widget to drag something to adjust an integer value in a range. Here we create a -horizontal one, set its range to 0-99 (inclusive, see the TQSlider::setRange() documentation) and its initial value to 0. -

        connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );
+horizontal one, set its range to 0-99 (inclusive, see the TQSlider::setRange() documentation) and its initial value to 0.
+

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

Here we use the signal/slot mechanism to connect the slider's valueChanged() signal to the LCD number's @@ -148,10 +148,10 @@ others stay about the same (because otherwise they would look stupid). makefile and build the application.)

Exercises

-

Try changing the LCD number to add more digits or to change mode. You can even add four push +

Try changing the LCD number to add more digits or to change mode. You can even add four push buttons to set the number base.

You can also change the slider's range. -

Perhaps it would have been better to use TQSpinBox than a slider? +

Perhaps it would have been better to use TQSpinBox than a slider?

Try to make the application quit when the LCD number overflows.

You're now ready for Chapter 6.

[Previous tutorial] -- cgit v1.2.3