m (N900: added forgotten "install")
(Linux: Corrected QtDesigner install command)
(2 intermediate revisions not shown)
Line 9: Line 9:
=== Linux ===
=== Linux ===
* Get QtDesigner
* Get QtDesigner
  sudo apt-get libqt4-designer  
  sudo apt-get install libqt4-designer  
* Get Qtruby and Ruby
* Get Qtruby and Ruby
  sudo apt-get install libqt4-ruby1.8
  sudo apt-get install libqt4-ruby1.8

Latest revision as of 09:03, 27 July 2012

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 without him.

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


[edit] Preperations

[edit] Linux

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

[edit] Windows

--Still need to test these directions on a win machine. But I think this is right.

gem install qtruby4

[edit] 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/

[edit] N900

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

[edit] Your First App

[edit] QtDesigner

  • Start QtDesigner:

It will open a window called “New Form”.

  • 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.

  • Select the Main Window in the Object Inspector.
  • In the Property Editor window scroll down till you see “geometry”.

You can expand the “geometry” stub by clicking on the triangle to the left of it.

  • 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.

  • Right click on the label and select “Change rich text”.

This gives you a WYSIWYG text editor.

  • 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

[edit] Rbuic

Now we need to translate the QtDesigner file into Ruby source code.

  • In Windows drop to a command prompt.
    • In linux open an xterm.
  • Navigate to the directory you save the form in.
rbuic4 -x dashboard_ui.ui -o dashboard_ui.rb

--note maybe just rbuic for windows.

[edit] Testing the app

  • From your apps directory type:
ruby dashboard_ui.rb


ruby1.8 dashboard_ui.rb

If all is well you will see your program appear. Congratulations!

[edit] Transfering it to the N900

  • Now copy dashboard_ui.rb to your N900 MyDocs folder.

-- add more directions here

[edit] Running your app on the N900

  • Open the Debian Chroot from your N900 programs menu.
cd home/user/MyDocs
ruby1.8 dashboard_ui.rb

[edit] 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.

[edit] Important Links