[Kde-bindings] Qyoto: SIGNALS/SLOTS
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Dec 13 20:47:43 UTC 2005
On Tuesday 13 December 2005 17:10, Adam Treat wrote:
> Hi all, I've been watching your discussion of SIGNALS/SLOTS for Qyoto and I
> wanted to offer up how this was solved in Qt# as I think it might reduce
> the work for you guys...
>
> Attached are three files that should be pretty much self contained drop in
> replacements for a signal/slot binding for Qyoto. The first one
> 'SigSlots.cs' will give you signal/slot functionality for C# <--> C#
> signals/slots and the second one 'NativeSigSlots.cs' will give you C++ <-->
> C# signals/slots as well as C# <--> C++ signals/slots.
>
> Finally, the file 'emit.cs' will show you how it all works.
>
> Here is what it looks like:
>
> namespace QtSamples
> {
> using Qt;
> using System;
>
> public class EmitSample: QVBox
> {
> public EmitSample (): base ()
> {
> QPushButton pb = new QPushButton ("Emit Sample",
> this);
>
> //pb.SIGNAL["Clicked()"] +=
> this.SIGNAL["EmitStuff()"];
> //this.SIGNAL["EmitStuff()"] +=
> this.SLOT["PrintStuff()"];
> }
>
> [SIGNAL]
> public void EmitStuff ()
> {
> Emit("EmitStuff()");
> }
>
> [SLOT]
> public void PrintStuff ()
> {
> Console.WriteLine ("Emitted 'EmitStuff()'");
> }
>
> public static void Main (string[] args)
> {
> QApplication app = new QApplication (args);
> EmitSample es = new EmitSample ();
> app.SetMainWidget (es);
> es.Show ();
> app.Exec ();
> }
> }
> }
>
> Feel free to use or ignore as is you like.
Thanks there's some good stuff here. The SIGNAL syntax looks interesting:
> //pb.SIGNAL["Clicked()"] +=
> this.SIGNAL["EmitStuff()"];
> //this.SIGNAL["EmitStuff()"] +=
> this.SLOT["PrintStuff()"];
I think we should carry on discussing the different ideas. The Smoke library
doesn't really dictate how slots/signals should be implemented. I copied the
way it was done in PerlQt for the QtRuby bindings, but we don't have to do
that. Although I was trying to get as much done in Qyoto for as little work
as possible, and copying the QtRuby way would be the line of least
resistance.
The way slots and signals are marked with SLOT and SIGNAL, as opposed to the
Q_SLOT() and Q_SIGNAL() we've been discussing is very similar.
[SIGNAL]
public void EmitStuff ()
{
Emit("EmitStuff()");
}
vs.
[Q_SIGNAL("EmitStuff()")]
public void EmitStuff();
...
((MyInterface) Emit()).EmitStuff()
-- Richard
More information about the Kde-bindings
mailing list