Results 1 to 2 of 2

Thread: QTextDocument::blockCount is always 1

  1. #1
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextDocument::blockCount is always 1

    I have a QTextEdit that I'm adding text to with insertHtml(). Its a combination of plaintext and true html thats added with that method. I'm using the QTextEdit as a logfile viewer of sorts. The trouble that I have is after a while, the QTextEdit has lots and lots of text in it. I want to create a cap on the number of lines that the QTextEdit displays.

    For starters, I need to get the number of text lines. What is confusing is that I call QTextEdit->document()->blockCount() and it always returns 1. I tried the more obvious lineCount() and it too returned 1. However the characterCount() returns what looks like a correct value.

    Theres like 100+ lines of text. Any ideas why blockCount is returning 1?

    Paul

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextDocument::blockCount is always 1

    I would assume that the way you use HTML makes the document keep all the data in one paragraph (block). Maybe instead of using insertHtml() you should use QTextCursor API?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QTextDocument question
    By chandan in forum Newbie
    Replies: 2
    Last Post: 14th May 2010, 14:08
  2. QTextDocument Html URL
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2008, 17:00
  3. QTextDocument and insertImage
    By bunjee in forum Qt Programming
    Replies: 13
    Last Post: 23rd January 2008, 21:03
  4. QTextDocument?
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 22:42
  5. QTextDocument stinks
    By elcuco in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2007, 12:30

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.