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-06.html | 96 +++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'doc/html/tutorial1-06.html') diff --git a/doc/html/tutorial1-06.html b/doc/html/tutorial1-06.html index e85f34bf..3c9f4c9c 100644 --- a/doc/html/tutorial1-06.html +++ b/doc/html/tutorial1-06.html @@ -43,46 +43,46 @@ widget as a child widget. ** ****************************************************************/ -#include <qapplication.h> -#include <qpushbutton.h> -#include <qslider.h> -#include <qlcdnumber.h> -#include <qfont.h> -#include <qvbox.h> -#include <qgrid.h> - -class LCDRange : public TQVBox +#include <ntqapplication.h> +#include <ntqpushbutton.h> +#include <ntqslider.h> +#include <ntqlcdnumber.h> +#include <ntqfont.h> +#include <ntqvbox.h> +#include <ntqgrid.h> + +class LCDRange : public TQVBox { public: - LCDRange( TQWidget *parent=0, const char *name=0 ); + LCDRange( TQWidget *parent=0, const char *name=0 ); }; -LCDRange::LCDRange( TQWidget *parent, const char *name ) - : TQVBox( parent, name ) +LCDRange::LCDRange( TQWidget *parent, const char *name ) + : TQVBox( parent, name ) { - TQLCDNumber *lcd = new TQLCDNumber( 2, this, "lcd" ); - TQSlider * slider = new TQSlider( Horizontal, this, "slider" ); - slider->setRange( 0, 99 ); - slider->setValue( 0 ); - connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) ); + TQLCDNumber *lcd = new TQLCDNumber( 2, this, "lcd" ); + TQSlider * slider = new TQSlider( Horizontal, this, "slider" ); + slider->setRange( 0, 99 ); + slider->setValue( 0 ); + connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) ); } -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()) ); - TQGrid *grid = new TQGrid( 4, this ); + TQGrid *grid = new TQGrid( 4, this ); for( int r = 0 ; r < 4 ; r++ ) for( int c = 0 ; c < 4 ; c++ ) @@ -91,12 +91,12 @@ public: 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(); } @@ -104,49 +104,49 @@ int main( int argc, char **argv )

Line-by-line Walkthrough

-

    class LCDRange : public TQVBox
+

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

The LCDRange widget is a widget without any API. It just has a constructor. This sort of widget is not very useful, so we'll add some API later. -

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

    LCDRange::LCDRange( TQWidget *parent, const char *name )
+            : TQVBox( parent, name )
     {
-        TQLCDNumber *lcd  = new TQLCDNumber( 2, this, "lcd"  );
-        TQSlider * slider = new TQSlider( Horizontal, this, "slider" );
-        slider->setRange( 0, 99 );
-        slider->setValue( 0 );
-        connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );
+        TQLCDNumber *lcd  = new TQLCDNumber( 2, this, "lcd"  );
+        TQSlider * slider = new TQSlider( Horizontal, this, "slider" );
+        slider->setRange( 0, 99 );
+        slider->setValue( 0 );
+        connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );
     }
 

This is lifted straight from the MyWidget constructor in Chapter 5. The only differences are that the button is left out and the class is renamed. -

    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, too, contains no API except a constructor. -

    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()) );
 

The push button that used to be in what is now LCDRange has been separated so that we can have one "Quit" button and many LCDRange objects. -

        TQGrid *grid = new TQGrid( 4, this );
+

        TQGrid *grid = new TQGrid( 4, this );
 
-

We create a TQGrid object with four columns. The TQGRid widget +

We create a TQGrid object with four columns. The TQGRid widget automatically arranges its children in rows and columns; you can specify the number of rows or of columns, and TQGrid will discover its new children and fit them into the grid. @@ -171,7 +171,7 @@ makefile and build the application.)

Initialize each slider with a different/random value on startup.

The source contains three occurrences of "4". What happens if you -change the one in the TQGrid constructor call? What about the other +change the one in the TQGrid constructor call? What about the other two? Why is this?

You're now ready for Chapter 7.

[Previous tutorial] -- cgit v1.2.1