Hi people,
I am trying to save to current cursor position, which i want to restore later on. It seems that restoring does not update the actual cursor. Here is a code snippet:
// in constuctor
void CCodeWidgetText::saveCursor()
{
this->cursorPos = this->pTextCursor->position();
}
void CCodeWidgetText::restoreCursor()
{
pTextCursor
->setPosition
(this
->cursorPos,
QTextCursor::MoveAnchor);
//this->setTextCursor(*pTextCursor);
}
// in constuctor
pTextCursor = new QTextCursor(this->document());
void CCodeWidgetText::saveCursor()
{
this->cursorPos = this->pTextCursor->position();
}
void CCodeWidgetText::restoreCursor()
{
pTextCursor->setPosition(this->cursorPos, QTextCursor::MoveAnchor);
//this->setTextCursor(*pTextCursor);
}
To copy to clipboard, switch view to plain text mode
Before this I tried to save the whole QTextCursor object and later on restore it, but that didn't seem to work either. Can someone help me out?
Thanks in advance
Bookmarks