QtRuby

QTRuby

This is a quick start guide to getting into QtRuby application development. Follow the KDE link at the bottom to take this further than what I have written so far. There is good info in mikec's thread as well that pertains to QtDesigner. Please feel free to add to this guide. Also please feel free to package an optified version of libqt so we don't need to use Easy Debian.

Extra special thanks to Qole for Easy Debian. None of this would be possible with out him.

I'm sure I've screwed something up so let me know in this thread. --add thread

Linux
sudo apt-get libqt4-designer sudo apt-get install libqt4-ruby1.8
 * Get QtDesigner
 * Get Qtruby and Ruby

Windows
--Still need to test these directions on a win machine. But I think this is right. gem install qtruby4
 * Get QtDesigner from http://qt.nokia.com/downloads
 * Get Ruby 1.87 from http://rubyinstaller.org
 * Install QtRuby4 gem from a command prompt

Mac
I'm not sure what all is gonna be required. Read this maybe: http://osake.wordpress.com/2009/08/21/qt4-qtruby-mac-os-x/

N900
debbie sudo apt-get libqt4-ruby1.8
 * Install Easy Debian (available in the extras repository)
 * Install ibqt4-ruby1.8 under Easy Debian using n900 terminal.

QtDesigner
It will open a window called “New Form”.
 * Start QtDesigner:
 * Select Main Window.
 * Change the Screen Size option to 800x400.
 * It may not be possible to do this depending on what platform you are on.
 * That's okay as we can change it later.
 * Click Create.

Our new form is created. We can now add controls to it and adjust its properties.


 * Click the View menu at the top of QtDesigner.
 * Check the Property Editor, Object Inspector and Widget Box if needed.

On the right side of the screen we see the Object Inspector and the Property Editor. You can click on any object in the Object Inspector and you will see that the Property Editor loads that object.

You can expand the “geometry” stub by clicking on the triangle to the left of it.
 * Select the Main Window in the Object Inspector.
 * In the Property Editor window scroll down till you see “geometry”.
 * Change the Width to 800 and the Height to 400 if necessary.

We don't need the Menu Bar or Status Bar that are default on a Main Window form. Let's remove them.
 * In the Object Inspector right click on the “menu bar” object.
 * Select “Remove Menu Bar”.
 * In the Object Inspector right click on the “status bar” object.
 * Select “Remove”.

Let's add a label to our form to display some text.

On the left side of our screen is the Widget Box. We can scroll through and pick widgets to add to our form.
 * Drag the “Label” widget under the “Display Widgets” category onto the form.

You will see a “TextLabel” with blue dots around it. You can drag the blue dots around to resize it. This gives you a WYSIWYG text editor.
 * Right click on the label and select “Change rich text”.
 * Type in “Hello World” (or whatever you like.)
 * Click “Ok” when finished.

In the Property Editor window adjust the geometry of the label to 800x400.

Now our form is complete.

Go to the File menu of QtDesigner and Save the form in a new directory somewhere. Name the form dashboard_ui.ui

Rubic
Now we need to translate the QtDesigner file into Ruby source code. rbuic4 -x dashboard_ui.ui -o dashboard_ui.rb --note maybe just rubic for windows.
 * In Windows drop to a command prompt.
 * In linux open an xterm.
 * Navigate to the directory you save the form in.

Testing the app
ruby dashboard_ui.rb or ruby1.8 dashboard_ui.rb If all is well you will see your program appear. Congratulations!
 * From your apps directory type:

Transfering it to the N900
-- add more directions here
 * Now copy dashboard_ui.rb to your N900 MyDocs folder.

Running your app on the N900
cd home/user/MyDocs ruby1.8 dashboard_ui.rb
 * Open the Debian Chroot from your N900 programs menu.

Revising Your First App For Single Inheritance
Coming Soon. We'll look at how to create a main.rb and subclass are ui to seperate the ui code from our program code.

Important Links
http://techbase.kde.org/Development/Tutorials/Developing_Qt4_Applications_using_Qt_Designer_and_Ruby_on_Kubuntu http://talk.maemo.org/showthread.php?t=43663 http://wiki.maemo.org/Easy_Debian
 * KDE QTRuby tutorial
 * mikec's Python/QtDesigner thread
 * Easy Debian wiki page