Results 1 to 6 of 6

Thread: Issue with QTextCursor, LineUnderCursor and a very long line

  1. #1

    Default Issue with QTextCursor, LineUnderCursor and a very long line

    I am trying to insert a long text (about 100 words), content in a xml section, inside a QTextEdit with HTML rich text.

    Example

    <text> Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. </text>

    When I insert the text it appers properly in the QTextEdit wrapped in 5 lines with widgetWidth wrapping, like this.

    Lorem ipsum ad his scripta blandit partiendo, eum fastidii
    accumsan euripidis in,eum liber hendrerit an. Qui ut wisi
    vocibus suscipiantur, quo dicit ridens inciderint id. Quo
    mundi lobortis reformidans eu, legimus senserit definiebas
    an eos.


    The problem appers when I try to get the first line with a QTextCursor::LineUnderCursor, it returns me like selectedText all the text (not the first line).

    Any idea?

    Thanks in advance

    K

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Issue with QTextCursor, LineUnderCursor and a very long line

    Welcome to the headaches of QTextCursor. In your case it is one line only. You are seeing it in multiple lines because QTextEdit::lineWrapMode() is on. So it wrapping up the text. But it still is only one line.

  3. #3

    Default Re: Issue with QTextCursor, LineUnderCursor and a very long line

    yes, but i need to return the content line by line, is there any way to detect the line wrapping with QTextCursor?

  4. #4
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Issue with QTextCursor, LineUnderCursor and a very long line

    Try QTextCursor::block()::text()

  5. #5

    Default Re: Issue with QTextCursor, LineUnderCursor and a very long line

    Thanks for your reply, it returns the content of the block text, that is the full text, not the first line :-(

  6. #6

    Default Re: Issue with QTextCursor, LineUnderCursor and a very long line

    I was trying this month with a lot of options, never good result, any suggestion?

Similar Threads

  1. qDebug() and long long int on WIN
    By iw2lsi in forum Qt Programming
    Replies: 3
    Last Post: 21st March 2012, 05:47
  2. Replies: 1
    Last Post: 26th August 2011, 09:51
  3. Replies: 7
    Last Post: 15th November 2010, 09:00
  4. "The input line is too long"
    By b1 in forum Installation and Deployment
    Replies: 1
    Last Post: 27th July 2008, 11:09
  5. how to srcoll a long text in one line from right to left?
    By deweyjew in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2006, 10:10

Tags for this Thread

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.