Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to trigger a signal in Qt

I've got an easy GUI window: a QLineEdit with a QPushButton. I want to trigger a signal when when the push button is clicked AND the input is validated (it meets a conditional statement, nevermind the details).

Normally I would use connect (object, signal, subject, slot). I guess that QPushButton clicked should trigger the middle-signal which is handled inside the widget slot. And the widget slot could trigger another signal - to my destination point. But how?

like image 785
ducin Avatar asked Jan 15 '23 08:01

ducin


1 Answers

You have to declare your signal in class:

class myClass
{
    /* stuff */
public signals: 
    void mySignal();
}

and in your code after validation:

void myClass::dataValidation()
{
    /*validate data*/
    emit mySignal();
}
like image 98
Blood Avatar answered Jan 25 '23 16:01

Blood