Cannot close the QT Program

Source: Internet
Author: User

Make a QT that cannot be closedProgram(You need to close it in the task manager when you want to close it.) It seems very difficult,

In fact, it is not difficult, as long as the program starts itself when it is closed.

UpperCode:

# Include <qtgui> class temp: Public qwidget {q_object PRIVATE: qlabel * label; protected: void closeevent (qcloseevent * event); Public: temp (qwidget * parent = 0 );~ Temp () ;}; temp: temp (qwidget * parent): qwidget (parent) {label = new qlabel ("you can't close me, haha. ", this); qvboxlayout * layout = new qvboxlayout; Layout-> addwidget (Label); setlayout (layout); move (200,200);} temp ::~ Temp () {} void temp: closeevent (qcloseevent * event) {// reload the relational event function, enable the program to re-open its qprocess * P = new qprocess (this); qstring STR = qapplication: applicationfilepath (); P-> startdetached (STR );} # include "Main. MOC "int main (INT argc, char * argv []) {qapplication app (argc, argv); temp * temp = new temp; temp-> show (); return app.exe C ();}

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.