Unsolved new SIGNAL / SLOT syntax
-
Hi,
in the old way we can write:
connect(worker , SIGNAL(_bigChip_changed(QImage)) ,this , SLOT(bigChip_update(QImage)));
I could find the syntax for new notation for "this":
connect(worker , &Worker::_bigChip_changed , this , ??::bigChip_update);
How can say
,this , SLOT(bigChip_update(QImage)))
in new notation
Thanks..
-
Use the type of
this
. See http://wiki.qt.io/New_Signal_Slot_SyntaxA real example:
class MyObject : public QObject{ Q_OBJECT Q_DISABLE_COPY(MyObject) public: explicit MyObject(QObject* parent=Q_NULLPTR) :QObject(parent) ,m_timer(new QTimer(this)) { connect(m_timer,&QTimer::timeOut,this,&MyObject::timerTimeOut); m_timer->start(1000); } private Q_SLOTS: void timerTimeOut(){qDebug("Timeout!");} private: QTimer* m_timer; };
It you like hurting yourself, you could use
connect(worker , &Worker::_bigChip_changed , this , &std::remove_const<std::remove_pointer<decltype(this)>::type>::type::bigChip_update);
but I see no scenario ever to use such a monstrosity
-
Hehe VRonin, thats cool.
Im not sure if it should come with warning, dont do this at home ;)So that basically strips the type info or what does it really do ?