Ruby/Qt 
Author Message
 Ruby/Qt

Is anyone using it?  How is it working out for you?

I've done a lot of Windows GUI work, but I'm a newcomer to Linux GUI
programming (haven't actually done a single one yet).  I'm pretty sold
on going with Qt from here on out, but before I had considered Qt, I was
already considering doing my basic GUI work (the support level I call
it) in Ruby, and calling C++ to do the core work.  Actually, I was going
start the application in C++, then load the Ruby bindings to handle the
fluffy user stuff (windows, menus, help, etc.), then on certain events,
the Ruby code would sometimes call back into the C++ application.

My reasoning is, once the application framework is set up, doing things
this way would allow me to protoype new features quickly and then I
could move my Ruby prototype code back into C++ for efficiency and
better integration with the rest of the application.

I did this a lot with Delphi, putting most of the application into a
DLL, using delphi for fluffy user stuff and prototyping, but moving code
into the DLL as I went along.  Worked pretty well.

Now I'm considering using Ruby for that user/prototyping part.  One of
my requirements/goals is that the UI toolkit go between X11 and Windows
fairly easily.  Maybe even Mac OS X.  Qt seems like the best route to
try that.

Anyone have any thoughts on Ruby/Qt?

        Sean



Tue, 02 Nov 2004 02:54:26 GMT  
 Ruby/Qt

Hi,

Quote:
> -----Original Message-----

> Sent: Thursday, May 16, 2002 9:02 PM
> To: ruby-talk ML
> Subject: Ruby/Qt

> Is anyone using it?  How is it working out for you?

Quite well, but of course, there are some limitations in
the current version. Not as good as SIP/PyQt for instance
(mainly it is difficult to override constructors and
virtual methods).

Quote:
> I've done a lot of Windows GUI work, but I'm a newcomer to Linux GUI
> programming (haven't actually done a single one yet).  I'm pretty sold
> on going with Qt from here on out, but before I had considered Qt, I was
> already considering doing my basic GUI work (the support level I call
> it) in Ruby, and calling C++ to do the core work.  Actually, I was going
> start the application in C++, then load the Ruby bindings to handle the
> fluffy user stuff (windows, menus, help, etc.), then on certain events,
> the Ruby code would sometimes call back into the C++ application.

> My reasoning is, once the application framework is set up, doing things
> this way would allow me to protoype new features quickly and then I
> could move my Ruby prototype code back into C++ for efficiency and
> better integration with the rest of the application.

You can safely mix C++ and Ruby, for sure.

Quote:
> I did this a lot with Delphi, putting most of the application into a
> DLL, using Delphi for fluffy user stuff and prototyping, but moving code
> into the DLL as I went along.  Worked pretty well.

> Now I'm considering using Ruby for that user/prototyping part.  One of
> my requirements/goals is that the UI toolkit go between X11 and Windows
> fairly easily.  Maybe even Mac OS X.  Qt seems like the best route to
> try that.

> Anyone have any thoughts on Ruby/Qt?

The bindings for Qt3 are still not available, but several people are
working on it.

Check also the Ruby/Qt group on Yahoo.

-- Christian



Tue, 02 Nov 2004 15:03:42 GMT  
 Ruby/Qt

Quote:

> (mainly it is difficult to override constructors and
> virtual methods).

Could you give an example on overriding a virtual method in
Qt2 binding of Ruby. Or some documentation in this regard?

Thanks, Christian



Tue, 02 Nov 2004 22:25:04 GMT  
 Ruby/Qt

Quote:


>> (mainly it is difficult to override constructors and
>> virtual methods).

> Could you give an example on overriding a virtual method in
> Qt2 binding of Ruby. Or some documentation in this regard?

> Thanks, Christian

for exemple, you cannot overload (or implement - whatever is the word)
the virtual method

    virtual void drawSplitter ( QPainter *, QCOORD x, QCOORD y, QCOORD w, QCOORD h )

In fact, if you do it (say write a method like

    def drawSplitter painter, x, y, w, h

        ...

    end

, it does nothing because the C++ implementation calls the C++ method and
*not* the ruby method.

Has someone a clue to overload virtual methods for ruby-Qt3 ?

Regards,

Pierre Brengard



Wed, 03 Nov 2004 00:20:27 GMT  
 Ruby/Qt

Quote:



>>> (mainly it is difficult to override constructors and
>>> virtual methods).

I hoped, it would be difficult, but possible...
I would have liked to see a solution, not an explanation, why it is
impossible.

Quote:
> for exemple, you cannot overload (or implement - whatever is the word)
> the virtual method

>    virtual void drawSplitter ( QPainter *, QCOORD x, QCOORD y, QCOORD w,
> QCOORD h )

> In fact, if you do it (say write a method like

>    def drawSplitter painter, x, y, w, h

>        ...

>    end

> , it does nothing because the C++ implementation calls the C++ method and
> *not* the ruby method.

It is quite clear (You can't manipulate the virtual method table in the runtime.)
The only solution I see is that the wrapper overloads ALL virtual functions and
the overloaded functions decide whether they call their "super" methods or not
dynamically. Of course, this would worsen the runtime considerably.
As far as I know the current qt-binding does not use this trick. So, I would
also believe that it is impossible to do this in the current binding.

Quote:
> Has someone a clue to overload virtual methods for ruby-Qt3 ?

The solution above could work. I think one should update the SWIG-ruby to behave this
way, at least optionally...

An optimized version of the above is to use inherit from each class a overridable
one if the class in question had virtual functions. You could decide: you want to use
the "unoverridable" but faster one, or the slower but more flexible class.
The drawback of this would be a more complicated interface.

Another proposal for the new Qt3 binding:

I would like to be able add Proc objects to blocks in a simple way.
(Without using signalConnect). E.g I would like to  be able to write:

onClicked do |item|
   ...
end

instead of:

connect(self,QSIGNAL("clicked(QListViewItem*)"),"slot_clicked")
def slot_clicked(item)
   ...
end

Best regards, Christian



Wed, 03 Nov 2004 01:16:55 GMT  
 Ruby/Qt

Quote:
> Now I'm considering using Ruby for that user/prototyping part.  One of
> my requirements/goals is that the UI toolkit go between X11 and Windows
> fairly easily.  Maybe even Mac OS X.  Qt seems like the best route to
> try that.

You might also want to look at FXRuby (http://www.fxruby.org) if a native
Mac OS X binding is not required. By "native", I'm referring to a version
that wouldn't require the end-user to run a X server on their Mac; we have
had reports in the past of success with building FOX on Mac OS X as a
X11-based library and then running FOX applications using XFree86 on Mac OS
X.

As an aside, some of the other responses to your post have veered off into a
discussion of Ruby/Qt's support for overriding virtual functions. This was
one of the up-front design requirements for FXRuby and as a result it works
pretty well. So, for example, you can derive a new class from one of the
existing FOX classes, override its virtual functions, and then those
functions will get called whenever the C++ library code invokes those
virtual functions.



Wed, 03 Nov 2004 10:16:30 GMT  
 Ruby/Qt

Quote:

> The bindings for Qt3 are still not available, but several people are
> working on it.

How close is it?  Is there any talk of doing a KDE extension to the binding?

--- SER



Fri, 05 Nov 2004 00:43:18 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Problems distributing my Ruby/Qt application

2. Very weird thing in Ruby/Qt

3. Help on installing ruby-qt on windowsXP

4. Ruby/Qt mailing-list

5. Qt/Tcl, Qt-Tcl, Qt Tcl

6. Looking for a "ruby-qt" for dummies reference

7. pthread trouble with ruby-opengl on FreeBSD (was: Re: [announcement] Ruby 3D Ruby)

8. Ruby books (Ruby NG FAQ, Ruby FAQ, home page)

9. ExternalInterface and qT (GTK)

10. QT movie with mask

11. quality of scalize in RB/QT very dirty ...

12. QT instance variable can't be modified

 

 
Powered by phpBB® Forum Software