[Development] templates as QObjects
Olivier Goffart
olivier at woboq.com
Fri Jun 22 09:26:31 CEST 2012
On Wednesday 20 June 2012 20:42:19 Peter Kümmel wrote:
> After the "noise" here "real" code:
>
> https://qt.gitorious.org/~syntheticpp/qt/qt4/commit/c1b839494d90e8c1a93b0dd2
> e08a2a365095d89f
>
> 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.
Nice stuff. Now you just need to make it for Qt5, and handle all the special
cases :-)
There is a room for tests in tets/auto/tools/moc (I'm saying that because you
made your test somewhere else)
--
Olivier
Woboq - Qt services and support - http://woboq.com
More information about the Development
mailing list