Results 1 to 3 of 3

Thread: Long text and word wrap in QPainter

  1. #1
    Join Date
    Apr 2009
    Posts
    75
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Long text and word wrap in QPainter

    Hi,

    I'ld like to print some text. Text is quite long (for example 1000 charcters). And I've text in QString text in one line (without any \n). I've tried to print it by:
    Qt Code:
    1. QRectF textArea(marginLeft,actTop,pageWidth,actLineHegiht);
    2. QRectF textArea3 = painter.boundingRect(textArea,Qt::TextWordWrap,tlumaczenie.at(1));
    3. painter.drawText(textArea, Qt::TextWordWrap, tlumaczenie.at(1),&textArea3);
    4. painter.drawRect( textArea3 );
    To copy to clipboard, switch view to plain text mode 
    And last code's (drawRect( textArea3 )) drawing me a multiline (I think so) area, but text is still in one line :/

    Why? How to print long text?

  2. #2
    Join Date
    Aug 2009
    Posts
    52
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Long text and word wrap in QPainter

    use QTextDocument

  3. #3
    Join Date
    Oct 2008
    Location
    Switzerland
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Long text and word wrap in QPainter

    Hi
    I'm displaying Strings with QGraphicsSceneTextItem.
    With TextItem text length can be determined:
    Qt Code:
    1. [INDENT][/INDENT]myTextItem->setTextWidth(100);
    To copy to clipboard, switch view to plain text mode 

    if will break the line automaticl

Similar Threads

  1. Layout long text in QTableWidget
    By Tamtam in forum Newbie
    Replies: 0
    Last Post: 13th February 2009, 15:09
  2. Qt layouting + QLabel's word wrap = bug?
    By dimuz in forum Qt Programming
    Replies: 6
    Last Post: 5th September 2007, 11:15
  3. Word wrap in QListView
    By jiveaxe in forum Qt Programming
    Replies: 33
    Last Post: 1st September 2007, 21:06

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.