From fef846914f8db6dc117e206ef913d519bf6bb33e Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 29 Jul 2024 12:43:23 +0900 Subject: Rename basic widget nt* related files to equivalent tq* Signed-off-by: Michele Calgaro --- doc/html/tutorial1-05.html | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'doc/html/tutorial1-05.html') diff --git a/doc/html/tutorial1-05.html b/doc/html/tutorial1-05.html index e5c0abe87..eecccbc7b 100644 --- a/doc/html/tutorial1-05.html +++ b/doc/html/tutorial1-05.html @@ -42,9 +42,9 @@ by using signals and slots, and how to handle resize events. ****************************************************************/ #include <ntqapplication.h> -#include <ntqpushbutton.h> -#include <ntqslider.h> -#include <ntqlcdnumber.h> +#include <tqpushbutton.h> +#include <tqslider.h> +#include <tqlcdnumber.h> #include <tqfont.h> #include <ntqvbox.h> @@ -59,18 +59,18 @@ public: MyWidget::MyWidget( TQWidget *parent, const char *name ) : TQVBox( parent, name ) { - TQPushButton *quit = new TQPushButton( "Quit", this, "quit" ); + TQPushButton *quit = new TQPushButton( "Quit", this, "quit" ); quit->setFont( TQFont( "Times", 18, TQFont::Bold ) ); connect( quit, TQ_SIGNAL(clicked()), tqApp, TQ_SLOT(quit()) ); - TQLCDNumber *lcd = new TQLCDNumber( 2, this, "lcd" ); + TQLCDNumber *lcd = new TQLCDNumber( 2, this, "lcd" ); - TQSlider * slider = new TQSlider( Horizontal, this, "slider" ); + TQSlider * slider = new TQSlider( Horizontal, this, "slider" ); slider->setRange( 0, 99 ); - slider->setValue( 0 ); + slider->setValue( 0 ); - connect( slider, TQ_SIGNAL(valueChanged(int)), lcd, TQ_SLOT(display(int)) ); + connect( slider, TQ_SIGNAL(valueChanged(int)), lcd, TQ_SLOT(display(int)) ); } int main( int argc, char **argv ) @@ -89,15 +89,15 @@ int main( int argc, char **argv )

Line-by-line Walkthrough

    #include <ntqapplication.h>
-    #include <ntqpushbutton.h>
-    #include <ntqslider.h>
-    #include <ntqlcdnumber.h>
+    #include <tqpushbutton.h>
+    #include <tqslider.h>
+    #include <tqlcdnumber.h>
     #include <tqfont.h>
 
     #include <ntqvbox.h>
 
-

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 +

Three new include files are shown here. tqslider.h and tqlcdnumber.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
     {
@@ -114,19 +114,19 @@ here because we use TQt's automatic layout support.
 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" );
+

        TQSlider * slider = new TQSlider( Horizontal, this, "slider" );
         slider->setRange( 0, 99 );
-        slider->setValue( 0 );
+        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, TQ_SIGNAL(valueChanged(int)), lcd, TQ_SLOT(display(int)) );
+

        connect( slider, TQ_SIGNAL(valueChanged(int)), lcd, TQ_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