Results 1 to 3 of 3

Thread: QTextBlock size when using QPlainTextEdit

  1. #1
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextBlock size when using QPlainTextEdit

    Can I be sure when iterating over text blocks in QPlainTextEdit that each block is one line exactly? (between /n .. /n)?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextBlock size when using QPlainTextEdit

    As long as I know: yes.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextBlock size when using QPlainTextEdit

    After digging the sources I came to QTextCursor::insertText() which is used by setPlainText() and there it is:
    Qt Code:
    1. if (ch == QLatin1Char('\n')
    2. || ch == QChar::ParagraphSeparator
    3. || ch == QTextBeginningOfFrame
    4. || ch == QTextEndOfFrame
    5. || ch == QLatin1Char('\r')) {
    6.  
    7. if (!hasEditBlock) {
    8. hasEditBlock = true;
    9. d->priv->beginEditBlock();
    10. }
    11.  
    12. if (blockEnd > blockStart)
    13. d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx);
    14.  
    15. d->insertBlock(blockFmt, format); // Here we go: a new block is inserted
    16. blockStart = i + 1;
    17. }
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to Lykurg for this useful post:

    dave (14th March 2010)

Similar Threads

  1. QPlainTextEdit and its size policy
    By Lykurg in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2010, 10:40
  2. QTextBlock::setVisible()
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 11th December 2009, 02:06
  3. Accessing the current QTextBlock in QSyntaxHighlighter
    By lorebett in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2008, 22:45
  4. QTextEdit and QTextBlock
    By Garfeild in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2008, 11:32
  5. Parse QTextBlock from QTextDocument problem
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 5th April 2008, 09:26

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.