Results 1 to 7 of 7

Thread: Is there a widget for display HTML files?

  1. #1
    Join Date
    May 2007
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Is there a widget for display HTML files?

    Is there a Qt widget that will allow me to populate it with HTML markup (including <img src="\dir\graphic.jpg">) for display to the user? It will need to be able to retrieve local images and provide hyperlinks. Is this possible?

    thanks,
    Jeff

  2. #2
    Join Date
    May 2007
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there a widget for display HTML files?

    Just found the QTextBrowser widget. This seems to display HTML and images. Although I can't seem to get the path correct for displaying an image currently. But I am sure I will figure it out.

    Jeff

  3. #3
    Join Date
    May 2007
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there a widget for display HTML files?

    Ok - how do I get a QTextBrowser to load and display a local HTML file? I seem to be having trouble understanding the C++ code required to do that. Assume the HTML file is in the program directory.

    Any quick help with the C++ code required to do this would be very helpful.

    Thanks,
    Jeff

  4. #4
    Join Date
    May 2007
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Cool Re: Is there a widget for display HTML files?

    Sorry to be wasting bandwidth here. I uncovered the answer via some extended searching in these forums.

    Qt Code:
    1. ui.textBrowser->setSource(QUrl("sample.htm"));
    To copy to clipboard, switch view to plain text mode 

    One problem however, I have a graphic file in the same directory as "sample.htm" - "icon5.gif". [WindowsXP, Visual Studio 2005]
    The setSrouce() call finds sample.htm, however, the textBrowser loads a "missing" graphic instead of the GIF file I referenced.

    Qt Code:
    1. <HTML>
    2. <HEAD>
    3. <META NAME="GENERATOR" Content="Microsoft Visual Studio 8.0">
    4. <TITLE></TITLE>
    5. </HEAD>
    6. <BODY>
    7. <h1>Introduction</h1>
    8. <p>This is the first paragraph</p>
    9. <ul>
    10. <li>Item 1</li>
    11. <li>Item 2</li>
    12. <li>Item 3</li>
    13. </ul>
    14. <p>
    15. <img src="icon5.gif" />
    16. </p>
    17. </BODY>
    18. </HTML>
    To copy to clipboard, switch view to plain text mode 

    Why can't the textBrowser find and display the graphic?

    Thanks,
    Jeff

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

    Default Re: Is there a widget for display HTML files?

    Maybe your Qt installation doesn't support gif images. Did you turn on GIF support for Qt? If not, then you've got your reason

  6. The following user says thank you to wysota for this useful post:

    JeffJones (24th May 2007)

  7. #6
    Join Date
    May 2007
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Is there a widget for display HTML files?

    It was a GIF issue. When I replaced the reference with a JPG file, it was displayed correctly.

    Now, the question begs - how does one turn on GIF support?

    And, if I may go ahead and piggy-back this thread with a further HTML-related question:

    Can the QtextBrowser display buttons and text fields and checkboxes?

    And, hoping that the answer is yes, can my code retrieve notification of button clicks; text from text fields and the status of said checkboxes?

    Thanks very much for your expertise!
    Jeff

  8. #7
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is there a widget for display HTML files?

    Quote Originally Posted by JeffJones View Post
    Now, the question begs - how does one turn on GIF support?
    You need to rebuild Qt with an option to configure to compile in GIF support: -qt-gif.

    Quote Originally Posted by JeffJones View Post
    Can the QtextBrowser display buttons and text fields and checkboxes?
    No it can't. It's not meant to be a full HTML browser engine, just a rich text display using as subset of HTML/CSS as the markup. However, in the future we will have a pure Qt WebKit, which will be a real HTML engine. It will be several months at least though.

Similar Threads

  1. Widget to display an HTML page ?
    By probine in forum Qt Tools
    Replies: 3
    Last Post: 11th October 2006, 19:55
  2. Qt html widget
    By js67257 in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2006, 15:34

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.