Translate
Appearance
Text
This page always uses small font size
Width
AllDevelopment/Tutorials/Qt4 Ruby Tutorial/Chapter 01
Translate to žemaitėška
Translation of the wiki page Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01 from English (en).
This tool does not work without JavaScript. JavaScript is disabled, failed to work, or this browser is unsupported.
Translations:Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01/Page display title/sgs
Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01
You need translation rights to translate messages.Get permission
Loading...
Latest updatesAll changes
Suggestions
In other languages
Need more help?Ask for more information
Translations:Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01/1/sgs
TutorialBrowser
You need translation rights to translate messages.Get permission
Loading...
Latest updatesAll changes
Suggestions
In other languages
Need more help?Ask for more information
This first program is a simple "Hello world" example.
It contains only the bare minimum you need to get a Qt application up and running.
The picture above is a screenshot of this program.
The top level in a QtRuby application usually only needs to perform some kind of initialization and then pass control to the Qt library,
which then tells the program about the user's actions via events.
There has to be exactly one [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] object in every GUI application that uses Qt.
[http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] manages various application-wide resources, such as the default font and cursor.
[http://doc.qt.nokia.com/latest/qpushbutton.html Qt::PushButton] is a GUI push button that the user can press and release.
It manages its own look and feel, like every other [http://doc.qt.nokia.com/latest/qwidget.html Qt::Widget].
A widget is a user interface object that can process user input and draw graphics.
The programmer can change both the overall look and feel and
many minor properties of it (such as color), as well as the widget's content.
A [http://doc.qt.nokia.com/latest/qpushbutton.html Qt::PushButton] can show either text or a [http://doc.qt.nokia.com/latest/qicon.html Qt::Icon].
'''<tt>app</tt>''' is this program's [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] instance. It is created here.
We pass '''<tt>ARGV</tt>''' to the [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] constructor
so that it can process certain standard command-line arguments (such as '''<tt>-display</tt>''' under X11).
All command-line arguments recognized by Qt are removed from '''<tt>ARGV</tt>'''.
<strong>Note:</strong> It is essential that the [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] object be created before any window-system parts of Qt are used.
Here, after the [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application], comes the first window-system code: A push button is created.
The button is set up to display the text "Hello world!".
Because we don't specify a parent window (as second argument to the
[http://doc.qt.nokia.com/latest/qpushbutton.html Qt::PushButton] constructor),
the button will be a window of its own, with its own window frame and title bar.
The button is set up to be 100 pixels wide and 30 pixels high
(excluding the window frame, which is provided by the windowing system).
We could call [http://doc.qt.nokia.com/latest/qwidget.html#pos-prop Qt::Widget::move()] to assign a specific screen position to the widget,
but instead we let the windowing system choose a position.
A widget is never visible when you create it. You must call [http://doc.qt.nokia.com/latest/qwidget.html#show Qt::Widget::show()] to make it visible.
This is where our program passes control to Qt.
[http://doc.qt.nokia.com/latest/qcoreapplication.html#exec Qt::CoreApplication::exec()] will return when the application exits.
([http://doc.qt.nokia.com/latest/qcoreapplication.html Qt::CoreApplication] is [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application]'s base class.
It implements [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application]'s core, non-GUI functionality and can be used when developing non-GUI applications.)
In [http://doc.qt.nokia.com/latest/qcoreapplication.html#exec Qt::CoreApplication::exec()], Qt receives and processes user and system events and passes these on to the appropriate widgets.
When you run the application, you will see a small window filled with a single button, and on it you can read the famous words: "Hello world!"
Try to resize the window. Click the button. If you're running X11,
try running the program with the '''<tt>-geometry</tt>''' option (for example, '''<tt>-geometry 100x200+10+20</tt>''').
Loading messages...
0% translated, 0% reviewed
Retrieved from "https://techbase.kde.org/Special:Translate"