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-04.html | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'doc/html/tutorial1-04.html') diff --git a/doc/html/tutorial1-04.html b/doc/html/tutorial1-04.html index 820cc797..c28d5ca5 100644 --- a/doc/html/tutorial1-04.html +++ b/doc/html/tutorial1-04.html @@ -41,41 +41,41 @@ minimum and maximum sizes of a widget, and introduces widget names. ** ****************************************************************/ -#include <qapplication.h> -#include <qpushbutton.h> -#include <qfont.h> +#include <ntqapplication.h> +#include <ntqpushbutton.h> +#include <ntqfont.h> -class MyWidget : public TQWidget +class MyWidget : public TQWidget { public: - MyWidget( TQWidget *parent=0, const char *name=0 ); + MyWidget( TQWidget *parent=0, const char *name=0 ); }; -MyWidget::MyWidget( TQWidget *parent, const char *name ) - : TQWidget( parent, name ) +MyWidget::MyWidget( TQWidget *parent, const char *name ) + : TQWidget( parent, name ) { - setMinimumSize( 200, 120 ); - setMaximumSize( 200, 120 ); + setMinimumSize( 200, 120 ); + setMaximumSize( 200, 120 ); - TQPushButton *quit = new TQPushButton( "Quit", this, "quit" ); - quit->setGeometry( 62, 40, 75, 30 ); - quit->setFont( TQFont( "Times", 18, TQFont::Bold ) ); + TQPushButton *quit = new TQPushButton( "Quit", this, "quit" ); + quit->setGeometry( 62, 40, 75, 30 ); + quit->setFont( TQFont( "Times", 18, TQFont::Bold ) ); - connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); + connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); } int main( int argc, char **argv ) { - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); MyWidget w; - w.setGeometry( 100, 100, 200, 120 ); - a.setMainWidget( &w ); - w.show(); - return a.exec(); + w.setGeometry( 100, 100, 200, 120 ); + a.setMainWidget( &w ); + w.show(); + return a.exec(); } @@ -83,13 +83,13 @@ int main( int argc, char **argv )

Line-by-line Walkthrough

-

    class MyWidget : public TQWidget
+

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

Here we create a new class. Because this class inherits from TQWidget, +

Here we create a new class. Because this class inherits from TQWidget, the new class is a widget and may be a top level window or a child widget (like the push button in Chapter 3).

This class has only one member, a constructor (in addition to the @@ -101,24 +101,24 @@ you specify a null pointer as the parent. As you can see, this widget defaults to be a top-level window.

The second argument is the widget's name. This is not the text that appears in the window's title bar or in the button. It is a name -associated with a widget to make it possible to look up this widget later, and there is -also a handy debugging function that will list a complete widget hierarchy. -

    MyWidget::MyWidget( TQWidget *parent, const char *name )
-            : TQWidget( parent, name )
+associated with a widget to make it possible to look up this widget later, and there is
+also a handy debugging function that will list a complete widget hierarchy.
+

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

The implementation of the constructor starts here. Like most widgets, -it just passes on the parent and name to the TQWidget +it just passes on the parent and name to the TQWidget constructor.

    {
-        setMinimumSize( 200, 120 );
-        setMaximumSize( 200, 120 );
+        setMinimumSize( 200, 120 );
+        setMaximumSize( 200, 120 );
 

Because this widget doesn't know how to handle resizing, we fix its size by setting the minimum and maximum to be equal. In the next chapter we will show how a widget can respond to resize event from the user. -

        TQPushButton *quit = new TQPushButton( "Quit", this, "quit" );
-        quit->setGeometry( 62, 40, 75, 30 );
-        quit->setFont( TQFont( "Times", 18, TQFont::Bold ) );
+

        TQPushButton *quit = new TQPushButton( "Quit", this, "quit" );
+        quit->setGeometry( 62, 40, 75, 30 );
+        quit->setFont( TQFont( "Times", 18, TQFont::Bold ) );
 

Here we create and set up a child widget of this widget (the new widget's parent is this) which has the widget name "quit". The widget @@ -132,7 +132,7 @@ when you choose to, the child will automatically tell TQt about its imminent death.)

The setGeometry() call does the same as move() and resize() did in the previous chapters. -

        connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
+

        connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
     }
 

Because the MyWidget class doesn't know about the application object, it @@ -145,13 +145,13 @@ so TQt offers an alias, qApp, for the cases in which a component such as MyWidget needs to talk to the application object.

    int main( int argc, char **argv )
     {
-        TQApplication a( argc, argv );
+        TQApplication a( argc, argv );
 
         MyWidget w;
-        w.setGeometry( 100, 100, 200, 120 );
-        a.setMainWidget( &w );
-        w.show();
-        return a.exec();
+        w.setGeometry( 100, 100, 200, 120 );
+        a.setMainWidget( &w );
+        w.show();
+        return a.exec();
     }
 

Here we instantiate our new child, set it to be the main widget, and @@ -166,7 +166,7 @@ makefile and build the application.)

Exercises

Try to create another MyWidget object in main(). What happens? -

Try to add more buttons or put in widgets other than TQPushButton. +

Try to add more buttons or put in widgets other than TQPushButton.

You're now ready for Chapter 5.

[Previous tutorial] [Next tutorial] -- cgit v1.2.1