Dissecting the SS
J Duncan
me at nospam.com
Thu Sep 28 16:40:31 PDT 2006
// what QT-style SS would look like in D
class AClass
{
void aSignal(int i);
}
class BClass
{
void aSlot(int i) { writefln("signal triggered %s", i); }
}
void main()
{
AClass a = new AClass;
BClass b = new BClass;
connect( a, "aSignal(int)", b, "aSlot(int)" );
a.aSignal(10); // -> writes "signal triggered 10"
}
i just wanted to give an example of how qt does it. the qt moc generates
the code for the function 'aSignal', this gives it a feeling like its
part of the language. the moc also generates code to map signal and slot
names to addresses. they also provide basic named properties (named data
members with set/get methods) this way. this results in a pretty nice
system that allows things like automatic signal slot connections in gui
classes based on names, (ex. the 'edit1' widget automatically sends a
'textChanged' signal to a slot on a parent widget called
'edit1_textChanged') i dont really have a point to make, i just wanted
to give a simple example of qt.
More information about the Digitalmars-d
mailing list