diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-01-26 23:32:43 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-01-26 23:32:43 -0600 |
commit | ea318d1431c89e647598c510c4245c6571aa5f46 (patch) | |
tree | 996d29b80c30d453dda86d1a23162d441628f169 /doc/html/tutorial1-10.html | |
parent | aaf89d4b48f69c9293feb187db26362e550b5561 (diff) | |
download | tqt3-ea318d1431c89e647598c510c4245c6571aa5f46.tar.gz tqt3-ea318d1431c89e647598c510c4245c6571aa5f46.zip |
Update to latest tqt3 automated conversion
Diffstat (limited to 'doc/html/tutorial1-10.html')
-rw-r--r-- | doc/html/tutorial1-10.html | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/doc/html/tutorial1-10.html b/doc/html/tutorial1-10.html index e25f0c194..cb4d0ed7d 100644 --- a/doc/html/tutorial1-10.html +++ b/doc/html/tutorial1-10.html @@ -66,7 +66,7 @@ implementation. </pre> <p> The interface to the force follows the same practice as for the angle. <p> <pre> private: - <a href="qrect.html">TQRect</a> cannonRect() const; + <a href="ntqrect.html">TQRect</a> cannonRect() const; </pre> <p> We have put the definition of the cannon's enclosing rectangle in a separate function. @@ -79,15 +79,15 @@ separate function. </h3> <a name="1-2"></a><p> -<p> <pre> #include <<a href="qpixmap-h.html">qpixmap.h</a>> +<p> <pre> #include <<a href="qpixmap-h.html">ntqpixmap.h</a>> </pre> -<p> We include the <a href="qpixmap.html">TQPixmap</a> class definition. -<p> <pre> CannonField::CannonField( <a href="qwidget.html">TQWidget</a> *parent, const char *name ) - : <a href="qwidget.html">TQWidget</a>( parent, name ) +<p> We include the <a href="ntqpixmap.html">TQPixmap</a> class definition. +<p> <pre> CannonField::CannonField( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name ) + : <a href="ntqwidget.html">TQWidget</a>( parent, name ) { ang = 45; f = 0; - <a href="qwidget.html#setPalette">setPalette</a>( TQPalette( TQColor( 250, 250, 200) ) ); + <a href="ntqwidget.html#setPalette">setPalette</a>( TQPalette( TQColor( 250, 250, 200) ) ); } </pre> <p> The force (<tt>f</tt>) is initialized to zero. @@ -100,7 +100,7 @@ separate function. if ( ang == degrees ) return; ang = degrees; - <a href="qwidget.html#repaint">repaint</a>( cannonRect(), FALSE ); + <a href="ntqwidget.html#repaint">repaint</a>( cannonRect(), FALSE ); emit angleChanged( ang ); } </pre> @@ -122,7 +122,7 @@ the drawing a little bit. <p> The implementation of setForce() is quite similar to that of setAngle(). The only difference is that because we don't show the force value, we don't need to repaint the widget. -<p> <pre> void CannonField::<a href="qwidget.html#paintEvent">paintEvent</a>( <a href="qpaintevent.html">TQPaintEvent</a> *e ) +<p> <pre> void CannonField::<a href="ntqwidget.html#paintEvent">paintEvent</a>( <a href="qpaintevent.html">TQPaintEvent</a> *e ) { <a name="x2357"></a> if ( !e-><a href="qpaintevent.html#rect">rect</a>().intersects( cannonRect() ) ) return; @@ -130,8 +130,8 @@ value, we don't need to repaint the widget. <p> We have now optimized the paint event to repaint only the parts of the widget that need updating. First we check whether we have to paint anything at all, and we return if we don't. -<p> <pre> <a href="qrect.html">TQRect</a> cr = cannonRect(); - <a name="x2361"></a> <a href="qpixmap.html">TQPixmap</a> pix( cr.<a href="qrect.html#size">size</a>() ); +<p> <pre> <a href="ntqrect.html">TQRect</a> cr = cannonRect(); + <a name="x2361"></a> <a href="ntqpixmap.html">TQPixmap</a> pix( cr.<a href="ntqrect.html#size">size</a>() ); </pre> <p> Then we create a temporary pixmap, which we use for flicker-free painting. All the painting operations are done into this pixmap, and @@ -141,31 +141,31 @@ precisely once. Less, and you get drawing errors. More, and you get flicker. It doesn't matter much in this example - when the code was written there were still machines slow enough for it to flicker, but not any more. We've kept the code for educational purposes. -<p> <pre> <a name="x2362"></a><a name="x2358"></a> pix.<a href="qpixmap.html#fill">fill</a>( this, cr.<a href="qrect.html#topLeft">topLeft</a>() ); +<p> <pre> <a name="x2362"></a><a name="x2358"></a> pix.<a href="ntqpixmap.html#fill">fill</a>( this, cr.<a href="ntqrect.html#topLeft">topLeft</a>() ); </pre> <p> We fill the pixmap with the background from this widget. -<p> <pre> <a href="qpainter.html">TQPainter</a> p( &pix ); - <a name="x2354"></a> p.<a href="qpainter.html#setBrush">setBrush</a>( blue ); - p.<a href="qpainter.html#setPen">setPen</a>( NoPen ); - <a name="x2359"></a><a name="x2356"></a> p.<a href="qpainter.html#translate">translate</a>( 0, pix.<a href="qpixmap.html#height">height</a>() - 1 ); - <a name="x2349"></a> p.<a href="qpainter.html#drawPie">drawPie</a>( TQRect( -35,-35, 70, 70 ), 0, 90*16 ); - <a name="x2353"></a> p.<a href="qpainter.html#rotate">rotate</a>( -ang ); - <a name="x2351"></a> p.<a href="qpainter.html#drawRect">drawRect</a>( TQRect(33, -4, 15, 8) ); - <a name="x2352"></a> p.<a href="qpainter.html#end">end</a>(); +<p> <pre> <a href="ntqpainter.html">TQPainter</a> p( &pix ); + <a name="x2354"></a> p.<a href="ntqpainter.html#setBrush">setBrush</a>( blue ); + p.<a href="ntqpainter.html#setPen">setPen</a>( NoPen ); + <a name="x2359"></a><a name="x2356"></a> p.<a href="ntqpainter.html#translate">translate</a>( 0, pix.<a href="ntqpixmap.html#height">height</a>() - 1 ); + <a name="x2349"></a> p.<a href="ntqpainter.html#drawPie">drawPie</a>( TQRect( -35,-35, 70, 70 ), 0, 90*16 ); + <a name="x2353"></a> p.<a href="ntqpainter.html#rotate">rotate</a>( -ang ); + <a name="x2351"></a> p.<a href="ntqpainter.html#drawRect">drawRect</a>( TQRect(33, -4, 15, 8) ); + <a name="x2352"></a> p.<a href="ntqpainter.html#end">end</a>(); </pre> <p> We paint, as in Chapter 9, but now we paint in the pixmap. <p> At this point, we have a painter variable and a pixmap that looks precisely right, but we still haven't painted on the screen. -<p> <pre> <a name="x2348"></a> p.<a href="qpainter.html#begin">begin</a>( this ); - <a name="x2350"></a> p.<a href="qpainter.html#drawPixmap">drawPixmap</a>( cr.<a href="qrect.html#topLeft">topLeft</a>(), pix ); +<p> <pre> <a name="x2348"></a> p.<a href="ntqpainter.html#begin">begin</a>( this ); + <a name="x2350"></a> p.<a href="ntqpainter.html#drawPixmap">drawPixmap</a>( cr.<a href="ntqrect.html#topLeft">topLeft</a>(), pix ); </pre> <p> So we open the painter on the CannonField itself and then draw the pixmap. <p> That's all. A couple of extra lines at the top and a couple at the bottom, and the code is 100% flicker-free. <p> <pre> TQRect CannonField::cannonRect() const { - <a href="qrect.html">TQRect</a> r( 0, 0, 50, 50 ); - <a name="x2360"></a> r.<a href="qrect.html#moveBottomLeft">moveBottomLeft</a>( <a href="qwidget.html#rect">rect</a>().bottomLeft() ); + <a href="ntqrect.html">TQRect</a> r( 0, 0, 50, 50 ); + <a name="x2360"></a> r.<a href="ntqrect.html#moveBottomLeft">moveBottomLeft</a>( <a href="ntqwidget.html#rect">rect</a>().bottomLeft() ); return r; } </pre> @@ -173,15 +173,15 @@ bottom, and the code is 100% flicker-free. coordinates. First we create a rectangle with the size 50x50 and then move it so its bottom left corner is equal to the widget's own bottom- left corner. -<p> The <a href="qwidget.html#rect">TQWidget::rect</a>() function returns the widget's enclosing +<p> The <a href="ntqwidget.html#rect">TQWidget::rect</a>() function returns the widget's enclosing rectangle in the widget's own coordinates (where the top left corner is 0, 0). <p> <h3> <a href="t10-main-cpp.html">t10/main.cpp</a> </h3> <a name="1-3"></a><p> -<p> <pre> MyWidget::MyWidget( <a href="qwidget.html">TQWidget</a> *parent, const char *name ) - : <a href="qwidget.html">TQWidget</a>( parent, name ) +<p> <pre> MyWidget::MyWidget( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name ) + : <a href="ntqwidget.html">TQWidget</a>( parent, name ) { </pre> <p> The constructor is mostly the same, but some new bits have been added. @@ -189,9 +189,9 @@ is 0, 0). force->setRange( 10, 50 ); </pre> <p> We add a second LCDRange, which will be used to set the force. -<p> <pre> <a href="qobject.html#connect">connect</a>( force, SIGNAL(valueChanged(int)), +<p> <pre> <a href="ntqobject.html#connect">connect</a>( force, SIGNAL(valueChanged(int)), cannonField, SLOT(setForce(int)) ); - <a href="qobject.html#connect">connect</a>( cannonField, SIGNAL(forceChanged(int)), + <a href="ntqobject.html#connect">connect</a>( cannonField, SIGNAL(forceChanged(int)), force, SLOT(setValue(int)) ); </pre> <p> We connect the <tt>force</tt> widget and the <tt>cannonField</tt> widget, just like @@ -218,8 +218,8 @@ makefile and build the application.) <a name="3"></a><p> Make the size of the cannon barrel be dependent on the force. <p> Put the cannon in the bottom-right corner. <p> Try adding a better keyboard interface. For example, make + and - -increase and decrease the force and enter shoot. Hint: <a href="qaccel.html">TQAccel</a> and -new addStep() and subtractStep() slots in LCDRange, like <a href="qslider.html#addStep">TQSlider::addStep</a>(). If you're bothered by the way the left and right +increase and decrease the force and enter shoot. Hint: <a href="ntqaccel.html">TQAccel</a> and +new addStep() and subtractStep() slots in LCDRange, like <a href="ntqslider.html#addStep">TQSlider::addStep</a>(). If you're bothered by the way the left and right keys work (I am!), change that too. <p> You're now ready for <a href="tutorial1-11.html">Chapter 11.</a> <p> [<a href="tutorial1-09.html">Previous tutorial</a>] |