My misunderstanding of qt citic and slot !!

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.