Results 1 to 13 of 13

Thread: Exception from moveToThread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    70
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    43
    Thanked 4 Times in 2 Posts

    Default Exception from moveToThread

    I have a QObject subclass that does some heavy processing—let's call it Processor. It reads in data from a file (or two), does stuff to the data, then writes a new file. I would like to move Processor to another thread so that my main application can continue operation while it processes. To me this sounds like a classic use of QThread.

    However, when I try QObject::moveToThread(), the program throws an exception and I can't figure out what I'm doing wrong. I'm trying to follow the concepts set forth here: http://labs.qt.nokia.com/2010/06/17/...oing-it-wrong/

    Here's a version of my code. Processor* "proc" and QThread* processingThread are private class members of MainWindow.

    Qt Code:
    1. processingThread = new QThread;
    2. proc = new Processor(/*send stuff to the constructor*/); //nothing is passed to the QObject constructor, so it should have no parent
    3. proc->moveToThread(processingThread); //exception here at QCoreApplication::notifyInternal(QObject*,QEvent*)
    4. //connect signals and slots between the processor and a QProgressDialog "pdia"
    5.  
    6. /* start processing */
    7. processingThreadstart();
    8. QTimer::singleShot(0, proc, SLOT(beginProcessing()));
    9. pdia->exec();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Exception from moveToThread

    Exception as in C++ exception or as in Windows Exception?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. MoveToThread clarification
    By Thuan Seah Tan in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2012, 10:32
  2. QMovie::moveToThread() and its QTimer
    By tiftof in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2011, 10:53
  3. moveToThread() Problem
    By rangerbob in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2009, 18:33
  4. QObject::moveToThread warning
    By mnemonic_fx in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2007, 22:11
  5. QObject::moveToThread() warnings
    By gri in forum Qt Programming
    Replies: 9
    Last Post: 2nd April 2007, 16:46

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
  •  
Qt is a trademark of The Qt Company.