How to manually call the signal of another control?

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?

+5
source share
6 answers

You could call this other button the click . It gives out a signal with a click.

+5
source

, ? ++, , . , (, clicked()). .

+3

++, . ( Qt 5, .)

0

Qt, moc, emit, .

, , - , , . , "" . , .

0

,

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

0
source

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();!

0
source

All Articles