QProgressBar + std::thread
Solved
General and Desktop
-
I have heavy task. I created QProgressBar for displaying that programm still work and runned heavy task in another thread using c++ std::thread class. But QProgressBar don't work, only window with QProgressBar starts, but QProgressBar don't appear in this window. Here is the code:
QProgressBar progress; progress.setRange(0, 0); progress.show(); if (keyLength == 1024) std::thread(&RSA::generateKeys, &rsa, RSA::RSA_1024).join(); else if (keyLength == 2048) std::thread(&RSA::generateKeys, &rsa, RSA::RSA_2048).join();
-
Hi,
From the looks of your progress bar is a local variable from your function so it will be destroyed at the end of the function hence no visibility.