3
votes

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?

1
If purpose is to do validation of user input, then also check out QValidator class, if you already have not.hyde

1 Answers

8
votes

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