Koto - Qt Users reimplement .ui.h with Ruby!

Iain Dooley idoo4002 at mail.usyd.edu.au
Thu Sep 1 12:46:34 CEST 2005


Well, autotools hasn't happened yet, but I'm working on it. In the 
meantime, if you download the package here:

http://rubyforge.org/projects/koto/

or checkout from:

/trunk/playground/network/koto/

I've put an INSTALL file in there with instructions on how to set the 
correct paths in the Makefile generated from qmake.

What you can do with Koto:

- Use Qt Designer to create your UI (there is a test one in the package 
called 'assign_some_text.ui') and edit connections to define the 
signals/slots

- Fire up Koto using ./runner (see README for more details) and go 
File/Open and select your .ui file (or type the path into the little url 
window and click the arrow)

- Click on the Project icon in the toolbar. You'll see a sample Ruby 
script popup in the code editor

- In the sample, you'll see declaration of 'slots'. These will 
eventually be generated straight from the .ui file, but for now, just 
copy and paste your .ui file signatures into the slots

- Now implement functions for each slot. The setParent function in the 
Ruby class is called when the program is first initialised. To see 
changes in the slots and/or the setParent function (the @parent argument 
is a QWidget object) you must click the Reinitialise button. Now 
whatever code you put in your Ruby class will handle the signal/slot 
connection present in the .ui file that you defined in Qt Designer

- If you change some details of a function implementation, you don't 
need to reinitialise, just click "Test the Code" and your changes will 
take effect immediately.

- You can open multiple .ui files. This demonstrates that Koto is very 
suitable as a KPart to embed scripted functionality into absolutely any 
Qt application (or KDE application, as this is easily ported to use 
Korundum)

Caveats:

- The install process is terrible. Email me with any questions or problems

- There is a bug that is possibly a problem with Qt Ruby (according to 
members of ruby-talk mailing list) that if you try and execute a member 
function of a non-existent child of the QWidget parent, then you will 
crash everything with a segmentation fault.

- Ruby attempts to garbage collect the QWidget when the program closes, 
but it has already been destroyed by the Koto program, so it says that 
there is a problem and dumps the core. This is pretty minor.

So all you Qt Designer users, particularly those with existing .ui.h 
file implementations, try reimplemenating your .ui.h file in Ruby with 
Koto and let me know how you go!!

I'm still going to be doing some debriefing with my mentors about the 
long term goals of this project, and I would like to thank Thiago 
Marcieira and Cornelius Schumacher for their outstanding support in what 
has been a big learning experience for me. I would also like to thank 
Google for the opportunity to participate, and everyone who has ever 
contributed to KDE for an awesome OS!!

cheers

iain


More information about the Kde-soc mailing list