Results 1 to 4 of 4

Thread: problem in setting cursor position in readOnly QTextEdit()

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem in setting cursor position in readOnly QTextEdit()

    hi friends ,
    how can i set the cursor position of a readonly QTextEdit() after it get input to the top position ...
    like this if the user click a button i am displaying a big paragraph but it showing only the tail position but i want to show the front text first ... i try
    Qt Code:
    1. QTextCursor cursor(editor->textCursor());
    2. cursor.movePosition(QTextCursor::Start);
    To copy to clipboard, switch view to plain text mode 
    but its not working ... i try setCursorPosition(1,1) but it says its not a member function ...
    then i tried
    Qt Code:
    1. resultTextEdit->cursorForPosition(startPos);
    To copy to clipboard, switch view to plain text mode 
    but i dont know how to set it ... please help ...
    please help

  2. #2
    Join Date
    Nov 2008
    Posts
    142
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem in setting cursor position in readOnly QTextEdit()

    Quote Originally Posted by wagmare View Post
    how can i set the cursor position of a readonly QTextEdit() after it get input to the top position ...
    like this if the user click a button i am displaying a big paragraph but it showing only the tail position but i want to show the front text first ... i try
    Qt Code:
    1. QTextCursor cursor(editor->textCursor());
    2. cursor.movePosition(QTextCursor::Start);
    To copy to clipboard, switch view to plain text mode 
    According to the documentation, QTextEdit::textCursor() returns a copy of the cursor, and changes to that do not affect the QTextEdit. Try to add a QTextEdit::setTextCursor() after the above code to tell the QTextEdit to use the modified cursor.

  3. The following user says thank you to rexi for this useful post:

    wagmare (22nd March 2009)

  4. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in setting cursor position in readOnly QTextEdit()

    Quote Originally Posted by rexi View Post
    According to the documentation, QTextEdit::textCursor() returns a copy of the cursor, and changes to that do not affect the QTextEdit. Try to add a QTextEdit::setTextCursor() after the above code to tell the QTextEdit to use the modified cursor.
    yes it worked , thanks a lot ....

  5. #4
    Join Date
    Sep 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Post Re: problem in setting cursor position in readOnly QTextEdit()

    this below code will work for setting the cursor position in read only mode....

    QTextCursor cursor(textEdit->textCursor());
    cursor.movePosition(QTextCursor::Start);
    textEdit->setTextCursor(cursor);

Similar Threads

  1. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 15:36
  2. QTextEdit problem
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 14th July 2006, 12:56
  3. setting cursor problem in QTextEdit
    By jyoti kumar in forum Qt Programming
    Replies: 3
    Last Post: 19th May 2006, 09:17
  4. lQtGuid4 error - Compiler setting problem
    By Kapil in forum Installation and Deployment
    Replies: 7
    Last Post: 10th February 2006, 10:30
  5. Problem with inserting text into QTextEdit
    By xorrr in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2006, 12:45

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.