Problems with Open-Source Downloads read and

(OSX?) Writing vector graphic data to the clipboard

  • I'm looking for a way to generate image data in vector form and copying it to the clipboard (to be pasted later on to other applications).

    Right now do one of two things:
    1: Generate a QPixmap, paint on it and use


    which works nicely for raster images

    2: Create a QPrinter, paint on it and generate a pdf file with the data in vector form.

    What I would like to do is generate the vector form but push it to the clipboard.

    Ive looked into how Illustrator generates clipboard data, and it creates a number of different copies of the data, in different formats (text/plain for the texts only, for the image, or com.adobe.pdf, which contains a proper pdf file, header and all).

    This has given me the idea of creating a pdf in a temp location with QPrinter, and then re-reading it and dumping it onto the clipboard. However I don't really know how I should go about setting the proper format for the mimeData.

    What I would do is:
    QByteArray data;
    // dump the pdf file data into data

    QString mimeType = "application/com.adobe.pdf";
    QMimeData* mimeData;
    mimeData->setData(mimeType, data);


    but this does not seem to be working: the format embedded in the mimetype (which I'm reading externally on the OS) is com.trolltech.anymime.application--com.adobe.pdf I imagine qt is using its own custom way of embedding mimedata formats for custom widgets (e.g. item-based models, etc).

    Interestingly enough when pasting from the clipboard data coming from illustrator, qt recognizes the data as application/x-qt-image , and


    returns true, but it is then unable to parse it (which seems obvious since it's a pdf file, not an image).

    So the question is:

    Is it possible to push a dump of a pdf file onto the clipboard (it should be), and if so how can I set the mimeData format manually (so that it doesn't append a "com.trolltech.anymime" in front of it?

Log in to reply