Qt5.0-beta1 QObject::connect return type and suggested framework operator
I'm pretty amazed how easy our migration to Qt5 was, but there was one change that I've needed to do and I think it could be taken into framework itself.
Compiler: gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
This lines of codes shows the case:
@ bool res = true;
res &= connect( this, SIGNAL(x()), this, SIGNAL(x2()));@
Qt4.8 passed this cause connect returned bool.
Qt5.0 returns QMetaObject::Connection and in this case we have compilation error caused by trying to do bitwise or on bool and QMetaObject::Connection.
To avoid changing code I've defined at global space this operator:
@bool& operator&=(bool& a_res, const QMetaObject::Connection& a_res2)
a_res = (a_res & static_cast<bool>(a_res2));
I hope it will help somebody or even get into Qt5.0
As the documentation says ("QMetaObject":http://doc-snapshot.qt-project.org/qt5-stable/qtcore/qmetaobject-connection.html ), the & should still work because the Connection defines operator bool()
Try it ;-)
is not a operator&=
"September 18, 2012" ;-D