But the cursor is set to -1 when no match is found by the find method in the findslot:
void FindWidget::slotFind()
{
if (cursor.anchor() == -1) {
cursor
= mTextpage
->document
()->find
(findEdit
->text
(), cursor,
QTextDocument::FindCaseSensitively);
} else {
cursor
= mTextpage
->document
()->find
(findEdit
->text
(), cursor.
anchor(),
QTextDocument::FindCaseSensitively);
}
mTextpage->setTextCursor(cursor);
this->setBackground();
}
void FindWidget::slotFind()
{
QTextCursor cursor = mTextpage->textCursor();
if (cursor.anchor() == -1) {
cursor = mTextpage->document()->find(findEdit->text(), cursor, QTextDocument::FindCaseSensitively);
} else {
cursor = mTextpage->document()->find(findEdit->text(), cursor.anchor(), QTextDocument::FindCaseSensitively);
}
mTextpage->setTextCursor(cursor);
this->setBackground();
}
To copy to clipboard, switch view to plain text mode
So my thought was, to set the position of the cursor in the slotClose to 0, if it is -1. But this doesn't work and I definetly don't understand why.
Bookmarks