Results 1 to 4 of 4

Thread: 2 questions on QPainter and html

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 2 questions on QPainter and html

    Hi,
    here are my questions:

    1) I have used QTextDocument for painting a html link; it is rendered but obviously i can't click on it for opening web browser. How can I accomplish this?

    2) Is QTextDocument the only class which permits rendering html code with qpainter? I ask for this because either, in my application, use always QTextDocument for rendering text or I have to do a lot of editing for rendering with the same look simple text in painter->drawText() and html text in QTextDocument.

    Thanks
    Giuseppe CalÃ

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: 2 questions on QPainter and html

    You can use QLabel for showing non-editable HTML, including links. QLabel can also automatically open external links for you, see property called openExternalLinks for more details.
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: 2 questions on QPainter and html

    Hi jpn,
    i know this property of QLabel but I have created a drawingArea and there, using a lot of painters in paintEvent, I am designing the interface; so I'm not sure of the final look if i put above this a QLabel.

    Regards
    Giuseppe CalÃ

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: 2 questions on QPainter and html

    Well, QTextDocument only describes a text document structure. Rendering it on arbitrary paint device doesn't give you text interaction of any kind. To be able to open links, you will have to catch mouse events by hand and use QDesktopServices to open URLs in external applications.
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.