Results 1 to 14 of 14

Thread: Add images or screenshots to a html doc

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2015
    Posts
    22
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Add images or screenshots to a html doc

    Hello,

    What I'm trying to do - print a PDF with my app logo, a chart (widget or image of the widget - any of those will do it) and the results - the chart is a container widget, I'm using QCustomPlot.

    What I'm doing right now - I'm writing a html and saving it as PDF.

    The problems:
    1 - I don't know how to insert images from my resources into the doc (solved);
    2 - I don't know how to insert the chart (or a screenshot of the chart) into the doc;
    3 - (minor problem) I need to remove the page number.


    Here's the code I have so far:
    Qt Code:
    1. doc.setHtml(
    2. "<h1 align='center'>App Title</h1><br>"
    3. "<img src='path_to_applogo/applogo.png'>"
    4. +ui->result_R->text()
    5. );
    6.  
    7. QPrinter printer(QPrinter::HighResolution);
    8. printer.setOutputFileName(filename);
    9. printer.setOutputFormat(QPrinter::PdfFormat);
    10. doc.print(&printer);
    To copy to clipboard, switch view to plain text mode 

    As you can see, I'm using an image from the user's computer, and not an image from the app's resources.
    Also, I don't know how to insert the chart or a screenshot of the chart into the html code, since the code will only accept strings.


    Thanks in advance.


    Problem 1 solved - After some more researching I found out i need to use the URL like this:
    Qt Code:
    1. "<p align='center'><img src=':/images/applogo.png'></p>"
    To copy to clipboard, switch view to plain text mode 
    Last edited by guiismiti; 8th February 2015 at 20:31.

Similar Threads

  1. Why the images from the HTML file is not loaded??
    By rleojoseph in forum Qt Programming
    Replies: 8
    Last Post: 2nd March 2011, 12:29
  2. How to use html to show overlapped images in QToolTip
    By LorenLiu in forum Qt Programming
    Replies: 0
    Last Post: 19th April 2010, 09:52
  3. GIF or MNG images for use in html for QTextBrowser
    By manojmka in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2008, 17:30
  4. Loading images in html in a QTextBrowser
    By BasicPoke in forum Newbie
    Replies: 1
    Last Post: 6th June 2007, 22:51
  5. getting images out of html
    By hijinks in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 00:17

Tags for this Thread

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.