<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://techbase.kde.org/skins/common/feed.css?0.2"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;feed=atom&amp;action=history</id>
		<title>Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01/en - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;action=history"/>
		<updated>2013-05-21T21:20:03Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;diff=72845&amp;oldid=prev</id>
		<title>FuzzyBot: Updating to match new version of source page</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;diff=72845&amp;oldid=prev"/>
				<updated>2012-07-13T12:32:08Z</updated>
		
		<summary type="html">&lt;p&gt;Updating to match new version of source page&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:32, 13 July 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;{{Template:I18n/Language Navigation Bar|Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{{TutorialBrowser|&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{{TutorialBrowser|&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>FuzzyBot</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;diff=61228&amp;oldid=prev</id>
		<title>Tampakrap: Updating to match new version of source page</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_01/en&amp;diff=61228&amp;oldid=prev"/>
				<updated>2011-07-02T14:47:21Z</updated>
		
		<summary type="html">&lt;p&gt;Updating to match new version of source page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:I18n/Language Navigation Bar|Development/Tutorials/Qt4 Ruby Tutorial/Chapter 01}}&lt;br /&gt;
&lt;br /&gt;
{{TutorialBrowser|&lt;br /&gt;
series=[[Special:myLanguage/Development/Tutorials/Qt4_Ruby_Tutorial|Qt4 Ruby Tutorial]]|&lt;br /&gt;
name=Hello World!|&lt;br /&gt;
pre=[http://www.ruby-lang.org Ruby]|&lt;br /&gt;
next=[[Special:myLanguage/Development/Tutorials/Qt4_Ruby_Tutorial/Chapter_2|Tutorial 2 - Calling it Quits]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Hello World! ==&lt;br /&gt;
[[Image:Qt4_Ruby_Tutorial_Screenshot_1.png|center]]&lt;br /&gt;
Files:&lt;br /&gt;
* [http://www.darshancomputing.com/qt4-qtruby-tutorial/tutorial/t1/t1.rb t1.rb]&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
This first program is a simple &amp;quot;Hello world&amp;quot; example. &lt;br /&gt;
It contains only the bare minimum you need to get a Qt application up and running. &lt;br /&gt;
The picture above is a screenshot of this program.&lt;br /&gt;
&lt;br /&gt;
Here's the complete source code for the application:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
require 'Qt4'&lt;br /&gt;
&lt;br /&gt;
app = Qt::Application.new(ARGV)&lt;br /&gt;
&lt;br /&gt;
hello = Qt::PushButton.new('Hello World!')&lt;br /&gt;
hello.resize(100, 30)&lt;br /&gt;
hello.show()&lt;br /&gt;
&lt;br /&gt;
app.exec()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intro ===&lt;br /&gt;
&lt;br /&gt;
The top level in a QtRuby application usually only needs to perform some kind of initialization and then pass control to the Qt library,&lt;br /&gt;
which then tells the program about the user's actions via events.&lt;br /&gt;
&lt;br /&gt;
There has to be exactly one [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] object in every GUI application that uses Qt. &lt;br /&gt;
[http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] manages various application-wide resources, such as the default font and cursor.&lt;br /&gt;
&lt;br /&gt;
[http://doc.qt.nokia.com/latest/qpushbutton.html Qt::PushButton] is a GUI push button that the user can press and release. &lt;br /&gt;
It manages its own look and feel, like every other [http://doc.qt.nokia.com/latest/qwidget.html Qt::Widget].&lt;br /&gt;
A widget is a user interface object that can process user input and draw graphics. &lt;br /&gt;
The programmer can change both the overall look and feel and &lt;br /&gt;
many minor properties of it (such as color), as well as the widget's content. &lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
=== Line by Line Walkthrough ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
require 'Qt4'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line loads the QtRuby extension.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
app = Qt::Application.new(ARGV)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;app&amp;lt;/tt&amp;gt;''' is this program's [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] instance. It is created here. &lt;br /&gt;
We pass '''&amp;lt;tt&amp;gt;ARGV&amp;lt;/tt&amp;gt;''' to the [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application] constructor&lt;br /&gt;
so that it can process certain standard command-line arguments (such as '''&amp;lt;tt&amp;gt;-display&amp;lt;/tt&amp;gt;''' under X11). &lt;br /&gt;
All command-line arguments recognized by Qt are removed from '''&amp;lt;tt&amp;gt;ARGV&amp;lt;/tt&amp;gt;'''. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
hello = Qt::PushButton.new('Hello World!')&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, after the [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application], comes the first window-system code: A push button is created.&lt;br /&gt;
&lt;br /&gt;
The button is set up to display the text &amp;quot;Hello world!&amp;quot;. &lt;br /&gt;
Because we don't specify a parent window (as second argument to the &lt;br /&gt;
[http://doc.qt.nokia.com/latest/qpushbutton.html Qt::PushButton] constructor), &lt;br /&gt;
the button will be a window of its own, with its own window frame and title bar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
hello.resize(100, 30)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The button is set up to be 100 pixels wide and 30 pixels high &lt;br /&gt;
(excluding the window frame, which is provided by the windowing system). &lt;br /&gt;
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, &lt;br /&gt;
but instead we let the windowing system choose a position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
hello.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
app.exec()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is where our program passes control to Qt. &lt;br /&gt;
[http://doc.qt.nokia.com/latest/qcoreapplication.html#exec Qt::CoreApplication::exec()] will return when the application exits. &lt;br /&gt;
([http://doc.qt.nokia.com/latest/qcoreapplication.html Qt::CoreApplication] is [http://doc.qt.nokia.com/latest/qapplication.html Qt::Application]'s base class. &lt;br /&gt;
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.)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
You should now try to run this program.&lt;br /&gt;
&lt;br /&gt;
=== Running the Application ===&lt;br /&gt;
&lt;br /&gt;
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: &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Exercises ===&lt;br /&gt;
&lt;br /&gt;
Try to resize the window. Click the button. If you're running X11, &lt;br /&gt;
try running the program with the '''&amp;lt;tt&amp;gt;-geometry&amp;lt;/tt&amp;gt;''' option (for example, '''&amp;lt;tt&amp;gt;-geometry 100x200+10+20&amp;lt;/tt&amp;gt;''').&lt;br /&gt;
&lt;br /&gt;
[[Category:Ruby]]&lt;/div&gt;</summary>
		<author><name>Tampakrap</name></author>	</entry>

	</feed>