Hello,
in a program I have the following code:
void FindWidget::slotClose() {
cursor = mTextpage->textCursor();
qDebug() << "cursor position on close start: " << cursor.position();
if ( cursor.position() == -1) {
qDebug() << "cursor position after setPosition: " << cursor.position();
mTextpage->setTextCursor(cursor);
}
mTextpage->setFocus();
close();
}
void FindWidget::slotClose() {
cursor = mTextpage->textCursor();
qDebug() << "cursor position on close start: " << cursor.position();
if ( cursor.position() == -1) {
cursor.setPosition(QTextCursor::Start,QTextCursor::MoveAnchor);
qDebug() << "cursor position after setPosition: " << cursor.position();
mTextpage->setTextCursor(cursor);
}
mTextpage->setFocus();
close();
}
To copy to clipboard, switch view to plain text mode
Example output is the following
cursor position on close start: -1
cursor position after setPosition: -1
cursor position on close start: -1
cursor position after setPosition: -1
To copy to clipboard, switch view to plain text mode
Anyone got an idea, what's goind wrong here? I also tried, not to use cursor as member and used the following instead:
QTextCursor cursor = mTextpage->textCursor();
To copy to clipboard, switch view to plain text mode
Also, same result.
Thanks in advance for any help.
Bookmarks