Results 1 to 7 of 7

Thread: QplainTextEdit

  1. #1
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default QplainTextEdit

    hello,

    how can I implement a function that will bring my cursor to a specific line number in a QPlainTextEdit window ?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QplainTextEdit


  3. #3
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default Re: QplainTextEdit

    ok thanks I actually saw this function but I was unsure this was the one I needed.
    How can I use it ?
    I don't really know what QTextCursor is, nor how to initialize it so that I could go to the line number I want.

  4. #4
    Join Date
    Sep 2008
    Location
    Munich
    Posts
    32
    Thanked 8 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QplainTextEdit

    For my knowledge you are looking for blocks (e.g. a text paragraph) http://doc.qt.nokia.com/4.6/richtext...ml#text-blocks and look for http://doc.qt.nokia.com/4.6/qtextdoc...ckByLineNumber.

    A QTextCursor accepts a QTextBlock during construction.

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QplainTextEdit

    A line ends with a carriage and linefeed. Count them. Use the position of the crlf combo + 2 to set your text cursor.
    Edit: or what jryannel says

  6. #6
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default Re: QplainTextEdit

    okay, so I tried this :
    void QPlainTextEdit::gotoLine(int n)
    {
    QTextCursor* test = new QTextCursor (this->findBlockByLineNumber(n));
    this->setTextCursor(test);
    }

    it seems I'm wrong.
    Can you help me to make it right ?
    Thanks

  7. #7
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default Re: QplainTextEdit

    This gives a compilation error, these functions can't be used with these classes, but I don't know how else to make it work.
    Can you help me please ?

Similar Threads

  1. QPlainTextEdit and anchors
    By bear101 in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2009, 18:10
  2. QPlainTextEdit, Read Only
    By metdos in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2009, 11:34
  3. QPlainTextEdit
    By Carlsberg in forum Qt Programming
    Replies: 4
    Last Post: 13th June 2009, 06:12
  4. QPlainTextEdit and mouseMoveEvent()
    By Carlsberg in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2009, 06:33
  5. QPlainTextEdit scrolling
    By roxton in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 16:55

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.