Results 1 to 3 of 3

Thread: Restoring cursor position in QTextEdit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Restoring cursor position in QTextEdit

    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:

    Qt Code:
    1. // in constuctor
    2. pTextCursor = new QTextCursor(this->document());
    3.  
    4. void CCodeWidgetText::saveCursor()
    5. {
    6. this->cursorPos = this->pTextCursor->position();
    7. }
    8.  
    9. void CCodeWidgetText::restoreCursor()
    10. {
    11. pTextCursor->setPosition(this->cursorPos, QTextCursor::MoveAnchor);
    12. //this->setTextCursor(*pTextCursor);
    13. }
    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
    Last edited by jpn; 30th May 2008 at 13:53. 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
  •  
Qt is a trademark of The Qt Company.