• Advertisement
Sign in to follow this  

Properly Closing a QT Application

This topic is 1384 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So Im making a QT application and Im trying to figure out how to properly shut it down when the x is clicked. I have a loop running and if the x is clicked the GUI will disappear while but the program keeps running until the loop ends. Calling delete on the object with the loop just stops the loop but doesnt stop the application.

 

So what is the best with of dealing with shut down. I assume its going to be using the closeEvent slot in some form.

Share this post


Link to post
Share on other sites
Advertisement

you need to close all threads created, not sure on the specifics of the program but whats happening is the gui is running on a different thread then the loop is if you detect that the x button is clicked have your loop thread close

Share this post


Link to post
Share on other sites

I was figuring it would be something along those lines. Thanks for pointing me in the right direction anyway. Anyone have more specifics for QT??

Share this post


Link to post
Share on other sites
Yes. The framework is called 'Qt' (note the lower case T).

Also, you might want to connect to this signal. Edited by BitMaster

Share this post


Link to post
Share on other sites
While I freely admit the initial version of my reply was not as useful as it could have been I'd also like to point out that downvoting it was unfriendly and unnecessary.

You are persistently calling a common library by the wrong name. Putting 'QT' instead of 'Qt' into a CV is quite likely to cause unnecessary problems for you (just like people writing 'JAVA' when they mean 'Java'). If there are a lot of potential candidates it might just be a reason to sort you into 'does not really know what he is talking about' instead of 'candidate'.

Share this post


Link to post
Share on other sites

If you wanted to say what you did the second time then say that. Making some comment to point out a simple mistake with no context and no relevance to the question at hand is bad for everyone. Thats why I downvoted. Unfriendly yes, unnecessary.... I would say not as I assume thats the point of the voting. And I understand your reasoning and its something I will take on board. But if you have a point then say it.

 

So anyway, does anyone have an answer for closing the main thread of the application.

Edited by walsh06

Share this post


Link to post
Share on other sites

Reading a short statement I found that using
QApplication::instance()->thread()
is how to obtain the main thread. From there you should be able to end / kill / purge the thread (the function may be called join, I am not sure).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement