Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProgressBar + std::thread

QProgressBar + std::thread

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 498 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    van9petryk
    wrote on last edited by van9petryk
    #1

    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();
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved