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.
void Thread::run()
{
assert(textEdit != 0);
assert(tree != 0);
while (true)
{
break;
if (cursor.hasSelection())
{
QString word
= cursor.
selectedText();
tree->insert(word); // *tree is going to be modified.
}
cursor.setPosition(cursor.selectionEnd());
}
}
void Thread::run()
{
assert(textEdit != 0);
assert(tree != 0);
QTextDocument *document = textEdit->document();
QTextCursor cursor(document);
cursor.movePosition(QTextCursor::Start);
while (true)
{
if (!cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor))
break;
if (cursor.hasSelection())
{
QString word = cursor.selectedText();
tree->insert(word); // *tree is going to be modified.
}
cursor.setPosition(cursor.selectionEnd());
}
}
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
Bookmarks