Results 1 to 4 of 4

Thread: QTextEdit restore cursor position

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextEdit restore cursor position

    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) :
    Qt Code:
    1. void MdiChild::setMdiWindowProperites(_editor_properites opt)
    2. {
    3. mdiWindowProperites = opt;
    4. setReadOnly(mdiWindowProperites.readOnly);
    5. setFont(QFont(mdiWindowProperites.fontName, mdiWindowProperites.fontSize, QFont::Normal));
    6. //editorOpt.lastDir = opt.lastDir;
    7.  
    8.  
    9. if(mdiWindowProperites.syntaxH)
    10. {
    11. if(highlighter <= 0)
    12. highlighter = new Highlighter(document(), mdiWindowProperites.syntaxHColors);
    13. if(highlighter > 0)
    14. highlighter->rehighlight();
    15. }
    16. else
    17. {
    18. if(highlighter > 0)
    19. delete(highlighter);
    20. highlighter = 0;
    21. };
    22.  
    23. textCursor().setPosition(mdiWindowProperites.cursorPosX);
    24. ensureCursorVisible();
    25. }
    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.
    Last edited by jpn; 25th May 2008 at 14:09. Reason: missing [code] tags

Similar Threads

  1. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  2. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.