Results 1 to 3 of 3

Thread: Problem with QTextDocument::drawContents(....)

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Problem with QTextDocument::drawContents(....)

    Hi,

    I'm unable to set display messages exchanged between to clients if I use QTextDocument::drawContents(...). But it's ok to use QPainter::drawText(...) method. Please look at the following code;

    Qt Code:
    1. QRect messageContentRect = messageFontMetrics.boundingRect(textOffset*4,
    2. rect.top() + textHeightInPixels + 13,
    3. rect.width() - (textOffset*4) - dateTimeTextWidthInPixels - 5 - 10 , 0,
    4. Qt::AlignLeft | Qt::AlignTop | Qt::TextWrapAnywhere,
    5. messageContent);
    6.  
    7. painter->setFont(messageFont);
    8. painter->setPen(QColor("#363636"));
    9. doc->setHtml(messageContent);
    10. //painter->drawText(messageContentRect, Qt::AlignLeft | Qt::AlignTop |Qt::TextWrapAnywhere, messageContent, &actuallyUsedRectForMessage); **** THIS IS OK
    11. painter->translate( messageContentRect.topLeft() );
    12. painter->translate( messageContentRect.bottomRight() );
    13. doc->drawContents(painter, messageContentRect); //**** THIS IS NOT OK
    To copy to clipboard, switch view to plain text mode 

    I want to use QTextDocument because I want to insert image for smileys. Any ideas?

    Regards, Zeki


    Added after 4 minutes:


    This link is exactly describes what I want...

    http://qt-project.org/forums/viewthread/30472
    Last edited by zgulser; 18th December 2013 at 16:09.

  2. The following user says thank you to zgulser for this useful post:


  3. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Problem with QTextDocument::drawContents(....)

    Nothing yet?

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Problem with QTextDocument::drawContents(....)

    What do you expect? You have not told us what, "THIS IS NOT OK" means.

    You get the text an no images?
    You get nothing?
    You get the raw HTML?
    Sure the HTML is valid?
    Have to tried without specifying a clipping rectangle?
    What else have you tried to debug it?

Similar Threads

  1. QTextDocument: print or drawContents?
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2010, 08:20
  2. Replies: 1
    Last Post: 19th August 2010, 13:10
  3. QTextDocument Image resource problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 15:28
  4. Reimplement QSplashScreen::drawContents
    By ucomesdag in forum Qt Programming
    Replies: 12
    Last Post: 24th November 2006, 09:39
  5. drawContents in QScrollArea (Qt4)
    By SkripT in forum Qt Programming
    Replies: 15
    Last Post: 14th January 2006, 10:54

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.