Results 1 to 6 of 6

Thread: QWebView problem with pdf

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    31
    Thanked 1 Time in 1 Post

    Default Re: QWebView problem with pdf

    The problem is the same with the use of a QWebPage class...

    Here is the code:

    Qt Code:
    1. #include <QtCore>
    2. #include <QtGui>
    3. #include <QtWebKit>
    4.  
    5.  
    6. int main(int argc, char *argv[]) {
    7. QApplication app(argc, argv, 1);
    8.  
    9. QPrinter *qPrinter = new QPrinter(QPrinter::HighResolution);
    10. qPrinter->setOutputFormat(QPrinter::PdfFormat);
    11. qPrinter->setOutputFileName("out.pdf");
    12.  
    13. QString text = "<html> <body> coucou <br>coucou br>coucou <br>coucou <br>coucou <br>coucou <br>coucou </body> </html>";
    14.  
    15. QWebPage *qWebPage = new QWebPage();
    16. qWebPage->mainFrame()->setHtml(text);
    17. qWebPage->setViewportSize(QSize(2000,2000));
    18. qWebPage->mainFrame()->print(qPrinter);
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

    Any idea of what I'm missing?

    Best regards,
    Oscar

  2. #2
    Join Date
    Sep 2007
    Posts
    31
    Thanked 1 Time in 1 Post

    Default Re: QWebView problem with pdf

    Well, I've found a html->pdf converter that's working.

    I was missing the following line:

    Qt Code:
    1. connect(qWebView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
    To copy to clipboard, switch view to plain text mode 

    Now, everything is ok.

    Best regards,
    Oscar
    Last edited by oscar; 23rd August 2008 at 16:12.

  3. The following user says thank you to oscar for this useful post:

    Cupidvogel (11th February 2016)

Similar Threads

  1. Problem With QWebView
    By ivi2501 in forum Qt Programming
    Replies: 8
    Last Post: 2nd August 2009, 19:37
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. QWebView unknown problem
    By morfei in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2008, 00:12
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.