qt5base-lts/tests/auto/corelib
Olivier Goffart 583c55b243 New QObject connection syntax
In addition to the old connection syntax, you can now connect using function pointers.

    connect(sender, &Sender::valueChanged,
            receiver, &Receiver::updateValue );

You can connect also to functor or C++11 lambdas

The connections are now type safe (no more problems with namespaces
or typedefs).  Implicit type conversion is also supported.

The new syntax forces us to change the meaning of signal form
protected to public, in order to be able to access the signal's
address everywhere

The way it works is by introducing new overload of QObject::connect
that take function pointer as parametter. Those new overload are template
function, that are implemented inline. The actual implementation is
in QObject::connectImpl which take a QObject::QSlotObject* as parametter
for the slot.  That slot object contains a virtual function which call
the slot which has to be implemented in the header as it depends on the
template parametter.  So the internals of QObjectPrivate::Connection
will store this QObjectSlot* in order to be able to make the call.

You can read a full description here:
http://developer.qt.nokia.com/wiki/New_Signal_Slot_Syntax

History of commits before it was imported on gerrit:
https://qt.gitorious.org/~ogoffart/qt/ogoffarts-qtbase/commits/qobject_connect_ptr

Thread on the mailing list:
http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000796.html
http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-September/001248.html
(The discussions on the mailing list were about trying to find a
solution that do not need making signals public, but no user friendly
solution was found)

Note: support for QueuedConnection, and the symetric QObject::disconnect is
added in another commit.
Qt::UniqueConnection is not supported yet in the new overload.

Change-Id: I67d08436b0720e7f2992be9f7e34770960fa58fa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-11-25 01:12:14 +01:00
..
animation qtbase tests: Fix some warnings 2011-11-21 09:58:23 +01:00
codecs Cleanup corelib autotests 2011-11-14 07:33:57 +01:00
concurrent Only use QVERIFY in test functions. 2011-11-24 05:56:48 +01:00
global Change the return value of QObject::connect 2011-11-25 01:12:14 +01:00
io Remove misleading comment. 2011-11-23 07:06:24 +01:00
kernel New QObject connection syntax 2011-11-25 01:12:14 +01:00
plugin Revert 3a0f5d04fc 2011-11-22 08:57:08 +01:00
statemachine Remove obsolete code from QStateMachine test. 2011-11-21 04:55:02 +01:00
thread qtbase tests: Fix some warnings 2011-11-21 09:58:23 +01:00
tools Improve QVector autotest 2011-11-24 10:38:15 +01:00
xml Cleanup corelib autotests 2011-11-14 07:33:57 +01:00
corelib.pro Exclude qtconcurrent tests via .pro files. 2011-10-12 18:01:19 +02:00