当前位置:网站首页>QT method of exiting application (exe)

QT method of exiting application (exe)

2022-06-25 21:13:00 Rabbit cloud program

When you want to exit the application , That is to close app When applied , At this point, you don't have to worry about the life cycle of processes and threads , In fact, even if you make the whole program close illegally when you exit , direct crash It's OK to drop it .

But as a good programmer, you should think more about it , Whether all memory is released when exiting , Check whether you should make a pop-up prompt for exit or a prompt for successful exit when exiting , It's more human , This is a must for programmers .

There is also a question about when you will send an exit app The order of , Or close the window , Before quitting, you can complete your business and logic , Without affecting the user experience . I saw someone sending out app Sleep when you quit 5s, Cause jamming delay .

QT There are several ways to exit the program in

Method 1:

 picture

Method 2:

 picture

You can add the above method to the slot function of the closing program . Of course, if you don't care Illegal closing , You can make one crash, Directly destruct an illegal pointer , cause app Flash back and collapse .

There is also a way to close the window :

    close()    // Just close a window   Also added to the slot function

First click on X when , Will respond to closeEvent event , So just do one thing in the event function

原网站

版权声明
本文为[Rabbit cloud program]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202181333005097.html