Results 1 to 5 of 5

Thread: Loop inside Qthread causes "QThread: Destroyed while thread is still running"?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Loop inside Qthread causes "QThread: Destroyed while thread is still running"?

    Hi, I am new to C++ and Qt and despite that i am thinking of using threads in my app. Here is an example code which outputs "." and then "QThread: Destroyed while thread is still running" error after pressing button.

    Qt Code:
    1. class MyThread : public QThread
    2. {
    3. public:
    4. void run();
    5. };
    6. void MyThread::run()
    7. {
    8. int connected=0;
    9. while (connected==0)
    10. {
    11. fprintf(stderr,".");
    12. //Do something that modifies num when usb device is connected
    13. sleep(5);
    14. }
    15. }
    16. void MainWindowImpl::on_button_clicked()
    17. {
    18. MyThread t;
    19. t.start();
    20. }
    To copy to clipboard, switch view to plain text mode 
    0
    What can be wrong in this code? Am I not allowed to use while loop in thread?
    Last edited by zolookas; 26th June 2008 at 17:07.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. QThread: Destroyed while thread is still running
    By Shuchi Agrawal in forum Newbie
    Replies: 8
    Last Post: 3rd April 2007, 06:27
  3. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.