Skip navigation.
KDE Developer's Journals

Qt4 QtRuby Windows port working

richard dale's picture

Congratulations to Ryan Hinton for getting a Windows port of the Smoke library and Qt4 QtRuby working. We just need to do a bit more to sync his version with the kde svn, and get it packaged. Then we're ready to do a first release that will run on Linux, BSD*, Mac OS X and Windows. Here's a couple of examples of how the ruby api improves on the original C++ one.

You can pass blocks to a constructor, which allows you to have your own 'custom constructor'. This is very nice for painter paths:

rectPath = Qt::PainterPath.new do |r|
    r.moveTo(20.0, 30.0)
    r.lineTo(80.0, 30.0)
    r.lineTo(80.0, 70.0)
    r.lineTo(20.0, 70.0)
    r.closeSubpath()
end

Or setting up widget layouts:

buttonLayout = Qt::HBoxLayout.new do |b|
    b.addStretch(1)
    b.addWidget(@okButton)
    b.addWidget(@cancelButton)
end

Any 'setFoobar(thing)' method can be written as 'foobar = thing', which makes the code more readable, especially when combined with constructor blocks like this:

slider = Qt::Slider.new(Qt::Vertical) do |s|
    s.setRange(0, 360 * 16)
    s.singleStep = 16
    s.pageStep = 15 * 16
    s.tickInterval = 15 * 16
    s.tickPosition = Qt::Slider::TicksRight
end

Of course you don't have to compile your code, and don't need the moc preprocessor. You don't appreciate how much of an advantage this is until you go back to C++, and it seems very old fashioned..

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
reynvlietstra's picture

Great

I'v been looking forward to this for so long Smiling
I cant find any additional information, is it in cvs somewhere ? Any idea on when we could expect a release ?

ltmon's picture

Thanks Richard!

Thanks for your great work.

I never got into Qt/KDE programming, because in the limited time for "hobby programming" I have left after my day job finishes I really felt that tweaking automake and it's ilk was a real drain of time.

I recently bought the QtRuby book (well... pdf) and have been having a great time ever since. It lets me get on with having fun programming without all the tedious bits. I'm looking forward to future improvements.

Cheers,

L.

yokem55's picture

Very Cool.

This is awesome. I'm learning Ruby right now (caught up in the craze called rails) and I've been looking forward to also learning what I can do with the QtRuby bindings as well.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.