I wanted to know if any particular signal through coding could emit it. For example, I want to fire another event with a button click, without the user actually clicking that button .. can I do this?
You could call this other button the click . It gives out a signal with a click.
, ? ++, , . , (, clicked()). .
clicked()
++, . ( Qt 5, .)
Qt, moc, emit, .
, , - , , . , "" . , .
,
emit signalName ( );
#include <QObject> class myClass : public QObject { Q_OBJECT public: myClass (QObject *parent = 0) : QObject(parent) { } void foo(); signals: void mySignal(int param); }; void myClass::foo() { emit mySignal(5); }
http://doc.qt.io/qt-4.8/signalsandslots.html
, mysignal , , http://doc.qt.io/qt-4.8/qobject.html#connect
if you set the action to a button, you can also just call the action that should be triggered. Just use it action_of_the_button->trigger();!
action_of_the_button->trigger();