Results 1 to 6 of 6

Thread: QPainter does not print html file as expected, ideas workarounds?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: QPainter does not print html file as expected, ideas workarounds?

    You couldn't search for "print" in the manual?
    Qt Code:
    1. QPrinter *printer;
    2. // set up printer
    3.  
    4. QWebView v;
    5. v.setHtml(html);
    6. v.show();
    7. v.print(printer);
    8.  
    9. // or without the view widget
    10. QWebPage page;
    11. page.mainFrame()->setHtml(html);
    12. page.mainFrame()->print(printer);
    To copy to clipboard, switch view to plain text mode 

    QTextDocument has a limited range of allowable HTML and does not cater for the huge range of malformed HTML in the wild. The browser components do, but they are much heavier components.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  2. #2
    Join Date
    Oct 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPainter does not print html file as expected, ideas workarounds?

    Quote Originally Posted by ChrisW67 View Post
    You couldn't search for "print" in the manual?
    Qt Code:
    1. QPrinter *printer;
    2. // set up printer
    3.  
    4. QWebView v;
    5. v.setHtml(html);
    6. v.show();
    7. v.print(printer);
    8.  
    9. // or without the view widget
    10. QWebPage page;
    11. page.mainFrame()->setHtml(html);
    12. page.mainFrame()->print(printer);
    To copy to clipboard, switch view to plain text mode 

    QTextDocument has a limited range of allowable HTML and does not cater for the huge range of malformed HTML in the wild. The browser components do, but they are much heavier components.
    Right, QWebPage could handle that monstruosity pretty well, thanks a lot!

Similar Threads

  1. Suggestions/Ideas about a file browser
    By SkripT in forum Qt Programming
    Replies: 31
    Last Post: 6th April 2011, 23:17
  2. how to print an html file?
    By patcito in forum Qt Programming
    Replies: 5
    Last Post: 31st August 2008, 16:50
  3. Replies: 4
    Last Post: 18th December 2007, 08:31
  4. Print html on fixed size
    By mamyte03@gmail.com in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2007, 10:33
  5. 2 questions on QPainter and html
    By jiveaxe in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2007, 11:30

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.