Hi.
I have problem with saving/restoring cursor position after closing/opening my application.
I use textCursor().position() to save position in QSettings and textCursor().setPosition() to restore it, but cursor always is on on position 0. Saving work's ok, if I look in settings file position looks correct.
How to fix this ?
Code (rest of code is based on Qt MDI example) :
void MdiChild::setMdiWindowProperites(_editor_properites opt)
{
mdiWindowProperites = opt;
setReadOnly(mdiWindowProperites.readOnly);
setFont
(QFont(mdiWindowProperites.
fontName, mdiWindowProperites.
fontSize,
QFont::Normal));
//editorOpt.lastDir = opt.lastDir;
if(mdiWindowProperites.syntaxH)
{
if(highlighter <= 0)
highlighter = new Highlighter(document(), mdiWindowProperites.syntaxHColors);
if(highlighter > 0)
highlighter->rehighlight();
}
else
{
if(highlighter > 0)
delete(highlighter);
highlighter = 0;
};
textCursor().setPosition(mdiWindowProperites.cursorPosX);
ensureCursorVisible();
}
void MdiChild::setMdiWindowProperites(_editor_properites opt)
{
mdiWindowProperites = opt;
setReadOnly(mdiWindowProperites.readOnly);
setFont(QFont(mdiWindowProperites.fontName, mdiWindowProperites.fontSize, QFont::Normal));
//editorOpt.lastDir = opt.lastDir;
if(mdiWindowProperites.syntaxH)
{
if(highlighter <= 0)
highlighter = new Highlighter(document(), mdiWindowProperites.syntaxHColors);
if(highlighter > 0)
highlighter->rehighlight();
}
else
{
if(highlighter > 0)
delete(highlighter);
highlighter = 0;
};
textCursor().setPosition(mdiWindowProperites.cursorPosX);
ensureCursorVisible();
}
To copy to clipboard, switch view to plain text mode
I use QT4.4.0 on openSUSE 10.3 KDE3.
Artur
PS.
Sorry for my bad English.
Bookmarks