Jump to content

Translate

AllDevelopment/Tutorials/Qt4 Ruby Tutorial/Chapter 10
Translate to Canadian English

Translation of the wiki page Development/Tutorials/Qt4 Ruby Tutorial/Chapter 10 from English (en) to Canadian English (en-ca)

You are translating into Canadian English. It is a variant of English, which is already the source language of these messages. Make sure the selected language is correct, and consider the differences across the language variants to provide a good translation.

This tool does not work without JavaScript. JavaScript is disabled, failed to work, or this browser is unsupported.
Development/Tutorials/Qt4 Ruby Tutorial/Chapter 10
Translations:Development/Tutorials/Qt4 Ruby Tutorial/Chapter 10/Page display title/en-ca
Development/Tutorials/Qt4 Ruby Tutorial/Chapter 10
You need translation rights to translate messages.Get permission
Latest updatesAll changes
Suggestions
In other languages
TutorialBrowser
Translations:Development/Tutorials/Qt4 Ruby Tutorial/Chapter 10/1/en-ca
TutorialBrowser
You need translation rights to translate messages.Get permission

name of wiki template

Latest updatesAll changes
Suggestions
In other languages
Qt4 Ruby Tutorial
Smooth as Silk
Tutorial 9 - With Cannon You Can
Tutorial 11 - Giving It a Shot
== Smooth as Silk ==
[[Image:Qt4_Ruby_Tutorial_Screenshot_10.png|center]]
Files:
=== Overview ===
In this example, we add a force control.
=== Line by Line Walkthrough ===
The '''<tt>CannonField</tt>''' now has a force value in addition to the angle.
The interface to the force follows the same practice as for the angle.
The force '''<tt>@currentForce</tt>''' is initialized to zero.
We have made a slight change in the '''<tt>setAngle()</tt>''' function. It repaints only the portion of the widget that contains the cannon.
The implementation of '''<tt>setForce()</tt>''' is quite similar to that of '''<tt>setAngle()</tt>'''. The only difference is that because we don't show the force value, we don't need to repaint the widget.
We paint as in Chapter 9.
The '''<tt>cannonRect()</tt>''' function returns the rectangle enclosing the cannon in widget coordinates. First we create a rectangle with the size 50 x 50 and then move it so its bottom-left corner is equal to the widget's own bottom-left corner.
The [http://doc.qt.nokia.com/latest/qwidget.html#rect-prop Qt::Widget::rect()] function returns the widget's enclosing rectangle in the widget's own coordinates. The top-left corner of the rectangle is always (0, 0).
The constructor is mostly the same, but some new bits have been added.
We add a second '''<tt>LCDRange</tt>''', which will be used to set the force.
We connect the '''<tt>force</tt>''' widget and the '''<tt>cannonField</tt>''' widget, just like we did for the '''<tt>angle</tt>''' widget.
In Chapter 9, we put '''<tt>angle</tt>''' in the lower-left cell of the layout. Now we want to have two widgets in that cell, so we make a vertical box, put the vertical box in the grid cell, and put each of '''<tt>angle</tt>''' and '''<tt>range</tt>''' in the vertical box.
We initialize the force value to 25.
=== Running the Application ===
We now have a force control.
=== Exercises === Make the size of the cannon barrel be dependent on the force.
Put the cannon in the bottom-right corner.
Try adding a better keyboard interface. For example, make + and - increase and decrease the force and enter shoot. If you're bothered by the way the '''<tt>Left</tt>''' and '''<tt>Right</tt>''' keys work, change that too. [Hint: Reimplement [http://doc.qt.nokia.com/latest/qwidget.html#keyPressEvent Qt::Widget::keyPressEvent()].]
[[Category:Ruby]]
Loading messages...
0% translated, 0% reviewed
All
Recent