[Kde-bindings] disconnecting a block in qtruby4

Richard Dale rdale at foton.es
Thu Jan 22 11:43:51 UTC 2009


On Wednesday 14 January 2009 10:53:00 Stefano Crocco wrote:
> Alle martedì 13 gennaio 2009, Richard Dale ha scritto:
> > The new Qt::SignalBlockInvocation will be a child of the thing you
> > connected it to, and so you can use thing.children obtain it and pass it
> > to a disconnect call perhaps. I can't think of a syntax for doing that
> > which would look tidy enough to be added to QtRuby at the moment though.
>
> Would it be possible to add another (optional) argument to the version of
> connect which takes a block? It could be used to be passed a string which
> will be set as object_name ofthe Qt::SignalBlockInvocation object, which
> can then be accessed using children as you suggested. Then connect could be
> called like this:
>
> obj.connect(SIGNAL(sig(int, QString)), "test_connection"){|n, s|...}
>
> I think that Internal.signal_connect could then become something like this:
>
>   def Internal.signal_connect(src, signal, block, name = nil)
>     args = (signal =~ /\((.*)\)/) ? $1 : ""
>     signature = Qt::MetaObject.normalizedSignature("invoke(%s)" %
> args).to_s obj = Qt::SignalBlockInvocation.new(src, block, signature)
>     obj.object_name = name if name
>     return Qt::Object.connect(  src,
>                   signal,
>                   obj,
>                   SLOT(signature) )
>   end
That is a possibility, but isn't it possible to autogenerate a name based on 
the name of the signal perhaps? 

I think a big problem with the current Qt4 QtRuby is the lack on documentation 
about the signals and slots options, and other things where the Ruby api 
differs from the C++ one. For instance, someone added an option to make it 
possible to call a method on any Ruby instance not just slots in Qt::Objects, 
which is very nice. But the only way I found out about it, was when I 
discovered the normal 3 arg connect() instance method no longer worked, as the 
change had broken it. There was no entry in the ChangeLog, the maintainer 
(myself) didn't know about it and there was nothing online anywhere either. So 
we could add the above change, but nobody would really know about it.

The Qt3 version of QtRuby had some quite good online docs, and we should try 
and get the KDE TechBase wiki up to a similar standard.

-- Richard



More information about the Kde-bindings mailing list