s.toonen
30th May 2008, 13:37
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
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);
}
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
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
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);
}
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