As we all know, a signal in QT can be connected to two slots. Today I want to try it out. I wrote a simple UI file, including a simple lineedit and a Pushbutton, and wrote two connect as follows:
Connect (Pushbutton, signal (clicked (), this, slots (serveropen (); Connect (Pushbutton, signal (clicked (), this, slots (serverclose ()));
Serveropen ()
{If (! Flag) {... // change the name of Pushbutton to flag = true ;.....}
}
Serverclose () {If (FLAG) {...... // change the name of Pushbutton to disabled flag = false ;.....}}
Originally, we thought that only one If statement was executed in the two slots above the button, but both functions were executed during the execution, and they were executed one after the other, later, I checked the data and found the signal and slot mechanism:
When a signal is connected to multiple slots, these slots are called one by one in an uncertain order during signal transmission.
Finally, I simply put both of the IF Statements in one slot.