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. (OSX?) Writing vector graphic data to the clipboard
Forum Updated to NodeBB v4.3 + New Features

(OSX?) Writing vector graphic data to the clipboard

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 700 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.
  • B Offline
    B Offline
    b4silio
    wrote on last edited by
    #1

    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

    @QApplication::clipboard()->setPixmap(myPixmap)@

    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, com.apple.pict 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);
    
    QApplication::clipboard()->setMimeData(mimeData);
    

    @

    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

    @QApplication::clipboard()->mimeData()->hasImage()@

    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?

    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