Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]How to catch error when printing QTextDocument to pdf when pdf is open?
Forum Updated to NodeBB v4.3 + New Features

[solved]How to catch error when printing QTextDocument to pdf when pdf is open?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qmlLearner
    wrote on last edited by
    #1

    Hi!
    I am printing a QTextDocument to a pdf with the following command:
    @doc.print(&printer);@

    It runs fine except when the pdf is already opened in a viewer (e.g. foxit reader), which makes sense as the printer doesn't have write permissions probably. Unfortunately, I haven't figured out how to catch this error, as the .print function is void. The only thing I see is the following on the console:
    @QPainter::begin(): Returned false@

    How can I catch this?
    Thank you for any help!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Maybe using QDir to list writable files before printing might work

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qmlLearner
        wrote on last edited by
        #3

        Thank you for you hint!
        The way I do it now is to try to open the file in write mode. If it is successful, I can continue with to printing, otherwise I throw an error.
        Thank you again for pointing me into this direction!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved