> > > Definitely no boilerplate code.
> >
> > I only see a chance with generated headers, or does 'boilerplate code'
> > mean only hand written code?
>
> Boilerplate means stuff you have to write to get things up and running.
>
OK, despite all the other points you mentioned I attach here a file which
demonstrates the idea I'm talking about. In principle it only "frees"
the signal and forwards the call to QObject::connect, which is already
implemented by Oliver, so I assume it supports all features of Oliver's
code. No boilerplate code to write, only the 'new and ugly' connect
call.
Peter
> As an example of what I don't like, check out GObject.
>
> And as an example of how I'd like it to be, check out my blog on a string
> table with no relocations in C++11.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
> PGP/GPG: 0x6EF45358; fingerprint:
> E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
Jetzt informieren: http://www.gmx.net/de/go/freephone
#undef QT_GUI_LIB
#include <QtTest>
#include <QCoreApplication>
#include <QObject>
#undef signals
#define signals protected
class tst_connect : public QObject
{
Q_OBJECT
public:
tst_connect() {}
private slots:
void noOverloads();
protected:
};
// for instance in qobjectdef.h or as member of QObject
template<class T>
struct connect;
// file
// <klass.h>
class Klass : public QObject
{
Q_OBJECT
public:
Klass() {}
signals:
void signalA();
public slots:
void slotA() {}
};
// </klass.h>
/*
generated by moc
*/
// <klass_moc.h>
template<>
struct connect<Klass>
{
template<class Sender, class Receiver, class Slot>
static bool signalA(Sender sender, Receiver receiver, Slot slot)
{
struct SignalAccess : Klass
{
static bool connect(Sender sender, Receiver receiver, Slot slot)
{
return QObject::connect(sender, &Klass::signalA, receiver,
slot);
}
};
return SignalAccess::connect(sender, receiver, slot);
}
};
// </klass_moc.h>
void tst_connect::noOverloads()
{
Klass sender;
Klass receiver;
QVERIFY( ::connect<Klass>::signalA(&sender, &receiver, &Klass::slotA) );
}
QTEST_MAIN(tst_connect)
#include "tst_connect.moc"
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback