Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QProgressBar + std::thread
van9petryk last edited by van9petryk
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();
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.