Results 1 to 3 of 3

Thread: QWebEnginePage::printToPdf() - how to tell when finished?

  1. #1
    Join Date
    Nov 2015
    Location
    Vermont
    Posts
    52
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QWebEnginePage::printToPdf() - how to tell when finished?

    I'm using the QWebEnginePage function printToPdf() to save a pdf file. I then want to open it in the appropriate application using QDesktopServices. When I try to do this, I am getting a ShellExecute failed error 2 (file not found). My problem seems to be that QDesktopServices tries to open the pdf before it is finished being created, because if I try to open that same exact same PDF using QDesktopServices the next time the program is run (by hardcoding the path in so it grabs the previously generated pdf as opposed to the one being created concurrently) it works fine. It there a way to determine when printToPdf has completed so I can trigger QDesktopServices after that? I can't seem to find any information on the topic other than this question from 8 months ago that remains unanswered.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QWebEnginePage::printToPdf() - how to tell when finished?

    Sadly that overload doesn't seem to have a result/status callback to allow the application to know when the operation ended.

    You could either use one of the other two print functions or monitor the target directory with a QFileSystemWatcher for the PDF to appear.

    Cheers,
    _

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

    ce_nort (21st February 2017)

  4. #3
    Join Date
    Nov 2015
    Location
    Vermont
    Posts
    52
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QWebEnginePage::printToPdf() - how to tell when finished?

    QFileSystemWatcher did the trick, thank you!

Similar Threads

  1. Replies: 2
    Last Post: 9th February 2017, 15:12
  2. Is QWebEnginePage::setHtml() synchronous or Asynchronous?
    By ayanda83 in forum Qt Programming
    Replies: 7
    Last Post: 12th January 2017, 09:42
  3. Replies: 4
    Last Post: 2nd May 2015, 12:09
  4. application finished, now what?
    By jbca in forum Newbie
    Replies: 2
    Last Post: 11th August 2010, 06:09
  5. which one has finished with QFutrueWatcher
    By wookoon in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2010, 12:41

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.