[SOLVED]I need explanation about connect()
-
Signal and slot mechanism is heart of qt.So i want to learn it thoroughly.There are somethings that preoccupies me. QObject::Connect() has five different form.One of them takes 3 arguments.Qt documentation(5.1.0) says about it that
@
QMetaObject::Connection QObject::connect(const QObject * sender, const char * signal, const char * method, Qt::ConnectionType type = Qt::AutoConnection) const
This function overloads connect().Connects signal from the sender object to this object's method.
Equivalent to connect(sender, signal, this, method, type).
Every connection you make emits a signal, so duplicate connections emit two signals. You can break a connection using disconnect().
Note: This function is thread-safe.
See also disconnect().
@
About "Equivalent to connect(sender, signal, this, method, type)." above:
1-Does class which pointing by *this have to be a subclass of QObject?
2-Does method had to be declared as custom slot?(in case of it is not member any QObject subclass)
3-Do I have to use SLOT macro such SLOT ( method ( args ) ) ?
4-Do I have to use Q_OBJECT macro in header?All questions above about qt5. Thanks.
-
Hi
- No, you can declare slots as public, protected or private.
- Using this form of connect, yes
- Yes you have to
You can read more about it in this "chapter":http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html