Results 1 to 2 of 2

Thread: how to move cursor to specific line in Text

  1. #1
    Join Date
    Jan 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile how to move cursor to specific line in Text

    hello everyone~~~ I've got a problem in processing text using QTextEdit API.I want the cursor in text move to specific line. ie: input 100 and the cursor move to NO.100 line!!
    QTextCursor::movePosition and QTextEdit::scrollToAnchor don't work. many thanks!!!!
    There is no secret in the face of the code.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to move cursor to specific line in Text

    Quote Originally Posted by showhand
    QTextCursor::movePosition and QTextEdit::scrollToAnchor don't work.
    Did you remember to set the cursor?
    Qt Code:
    1. QTextCursor cursor = textEdit->textCursor();
    2. cursor.movePosition(..);
    3. textEdit->setTextCursor(cursor); // maybe you forgot this?
    To copy to clipboard, switch view to plain text mode 

    Check this thread out. That piece of code gives you the current line number of the cursor. With sligth modifies you can move the cursor to a specific line.
    J-P Nurmi

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. count line number in text
    By Alina in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 08:29
  3. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  4. How to get text of last line only in QTextEdit?
    By rajesh in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2006, 13:37
  5. Replies: 1
    Last Post: 17th March 2006, 08:19

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.