[Development] templates as QObjects
Peter Kümmel
syntheticpp at gmx.net
Wed Jun 20 20:42:19 CEST 2012
After the "noise" here "real" code:
https://qt.gitorious.org/~syntheticpp/qt/qt4/commit/c1b839494d90e8c1a93b0dd2e08a2a365095d89f
Based on Qt 4.8.2.
moc creates a header when it finds a template, if not then nothing changes.
(It builds Qt with the patch, but it's a hack in the parser)
In summary
Foo<int> foo1;
Foo<int> foo2;
Foo<double> foo3;
// works
QObject::connect(&foo1, SIGNAL(asignal(T)), &foo2, SLOT(aslot(T)));
// this should be possible, but string matching fails
// no problem in Qt5
QObject::connect(&a, SIGNAL(asignal(int)), &foo1, SLOT(aslot(T)));
// this should not be possible, but it runs because of the (void*) casts in the background
// maybe catched in Qt5
QObject::connect(&foo1, SIGNAL(asignal(T)), &foo3, SLOT(aslot(T)));
It's only an experiment, to see what could be done without using clang.
Maybe I bring it up at the QtCS.
Peter
More information about the Development
mailing list