Qt C++ preventing program to show error-messages when busy

147 Views Asked by At

Hi I have a question concerning error-messages.

I have a window with several buttons including a OK and Cancel-button. My OK-button executes a program that moves some chart series and for doing so it needs to read in lots of data from a file and shift these values. The Cancel button cancels this operation. The calculations cannot be separated into smaller portions of code.

This works well for smaller amount of data but when I use it with large sets of data the program acts as if it crashed. Nevertheless, after some time everything is back to normal, the calculation is done.

There are 2 things I don`t like:

  • 1) When I leave the program alone the program changes the headerline of my window to ....(keine Rückmeldung) which means no response.

    enter image description here

    After the end of the calculation the text ...(keine Rückmeldung) disappears in the header and everything is back to normal.

  • 2) When I try to press the "cancel" button in my window while running the calculation, an additional window appears:

    enter image description here

    There again, when I leave the program alone and the calculation is finished this window disappears ( as well as the (keine Rückmeldung) in the header of my window) and and everything is back to normal.

To solve problem 2 I tried to disable my "Cancel" button but this does not help. The slot which is behnid the cancel-button gets executed anyway.

My question now is: Since I don´t want the user to see these error-messages, is there a way to prevent the program of showing them?

Thank you

1

There are 1 best solutions below

0
On

Consider using a QThread for expensive computation tasks. Or better, you can use other built-in multi-threading utilities such as QConcurrentRun and QFuture.

You can then easily get the state of your background function and show a loading Window, or allow the user to perform other operations in the meantime.