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. QPrinter setIODevice
Forum Update on Monday, May 27th 2025

QPrinter setIODevice

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.4k Views
  • 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
    QBall
    wrote on last edited by
    #1

    Hi All,

    I was wondering if I could get QPrinter to output the resulting pdf/ps to a QIODevice as opposed to supplying a OutputFileName. I am doing a pdf creation and am unable to get access to the file system. I noticed in the class QPdfEngine (which is not part of the API) there is a method setIODevice(QIODevice *) which could possibly be called with a QBuffer.

    Is there a way we can access this or would one have to add a method to QPrinter class (which would in turn call the print engine) and recompile Qt accordingly. Can one do this on a LGPL licence?

    Maybe there is a better way of doing this...

    Any help is appreciated.

    Cheers

    Q

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      any specific reason why you are not able to get access to file system?

      I think you could just use QPainter, set the appropriate QPaintDevice and also accomplish what you want to do.

      also from the docs:
      The drawing capabilities of QPaintDevice are currently implemented by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and QPrinter subclasses.
      To implement support for a new backend, you must derive from QPaintDevice and reimplement the virtual paintEngine() function to tell QPainter which paint engine should be used to draw on this particular device. Note that you also must create a corresponding paint engine to be able to draw on the device, i.e derive from QPaintEngine and reimplement its virtual functions.

      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