[QT Development] set input wait in qt gui Programming

Source: Internet
Author: User

For example, a Q & A GameProgramThe program will continue to ask the next question only after entering the answer to the current question,

The input answer is manipulated by players, and the program must monitor the input at any time.

This problem can be easily solved in the console, and it must be solved by threads in qt gui applications,
# Include <windows. h> </P> <p> //...... <SPAN class = 'wp _ keywordlink '> Code </span> omitted <br/> while (! Issend) // issend is the validation variable for the input answer <br/>{< br/> qcoreapplication: processevents (); // UI refresh supported <br/> sleep (300); // The current thread sleeps for a period of time (0.3 s ), avoid occupying CPU all the time <br/>}// if you are sure to enter the answer, that is, if issend is true, the loop is displayed. <br/> issend = false; <br/> // action generated based on the current problem <br/> //... if you want to continue to raise questions, you can continue the cycle <br/>

 

Sync blog:Http://moxiaomomo.iteye.com/blog/1066709

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.