[Kde-bindings] Ruby Qt4 + net/http operations

Richard Dale rdale at foton.es
Wed Oct 1 12:37:36 UTC 2008


On Wednesday 01 October 2008 09:51:21 Ruben Fonseca wrote:
> Hi @all!
>
> I'm doing some experiments with Ruby Qt4 (using version 1.4.10 on Debian
> unstable).
>
> I was trying to build a GUI to a library I wrote that interacts with a
> website using its API. However, I run into difficulties when trying to
> integrate my library (that mainly uses net/http to make HTTP calls) with
> Qt4.
>
> AFAIK, Ruby Qt4 currently does not support QThread objects. Since my
> library blocks on network operations, I couldn't find a way to integrate
> it with Qt4.
>
> I've tried to create a Ruby thread:
>
> def button_clicked
>    Thread.new {
> 	# do my blocking networking code
>    }
> end
>
> but the thread seems to freeze somehow during the network operation
> (weird..)
>
> the other think I've tried was to add the operation to a
> QTimer.singleShot block. However, while the code is running, the entire
> GUI is frozen (which I think makes sense).
>
> Is it possible to do this kind of stuff with the current Qt4 Ruby
> bindings?
Yes, but you need to use the Qt networking classes like Qt::Http and 
Qt::SocketNotifier which are integrated with the Qt event loop. They are no 
harder to use than the Ruby Net/Http ones, and I would just convert your 
calls.

-- Richard



More information about the Kde-bindings mailing list