Hi I have a question.

In the code, textEdit is a pointer of a class that inherits from QTextEdit class, and is owned by the main window, tree is a pointer of a Tree class I created, and is owned by a dialog.

Qt Code:
  1. void Thread::run()
  2. {
  3. assert(textEdit != 0);
  4. assert(tree != 0);
  5.  
  6. QTextDocument *document = textEdit->document();
  7. QTextCursor cursor(document);
  8.  
  9. cursor.movePosition(QTextCursor::Start);
  10.  
  11. while (true)
  12. {
  13. if (!cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor))
  14. break;
  15.  
  16. if (cursor.hasSelection())
  17. {
  18. QString word = cursor.selectedText();
  19. tree->insert(word); // *tree is going to be modified.
  20. }
  21. cursor.setPosition(cursor.selectionEnd());
  22. }
  23. }
To copy to clipboard, switch view to plain text mode 

When I open the dialog, I want the thread to start.

But I'm getting this error.

ASSERT: "qApp && qApp->thread() == QThread::currentThread"

Is this because I'm not using lockers or mutexs? How should I use them?.

Also, I want to receive a signal when run has finished.
Should I use terminated signal, finished signal or create my own signal?

Thanks