Results 1 to 5 of 5

Thread: Copying Vector Images to the Windows Clipboard

  1. #1
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Copying Vector Images to the Windows Clipboard

    Hey Everyone,

    I've been thinking about how to solve this for a long time, but haven't come up with anything satisfactory.

    Basically, I have a graphicsview scene with some boxes and lines, and I want to be able to copy a part of that scene and paste it into an application like MS Word. The way I do it right now is to find the area that was selected, then render that area to an image and put it into the clipboard buffer. That works ok, but it's rendered as an image, so resizing it in word will degrade the quality very badly.

    So what I really want is to copy it in some sort of vector format, so that Word will be able to resize it properly. Now on Windows my best bet seems to be EMF/WMF, which is a vector format basically consisting of GDI drawing commands. Obviously Qt can't export that (as far as I can tell), so I'll need to convert from one of the formats that Qt can create (SVG and PDF would be the best candidates I guess).

    So has anyone approached this problem before? I can't find any good libraries that will allow me to convert svg or pdf to EMF/WMF, or more generally, how to copy vector data to the windows clipboard. Any suggestions?

    I've tried uniconverter which claims to convert SVG to WMF, but it just produced garbage on a sample file I had. Another shareware converter also produced inaccurate results. Seems like it's not an easy task.
    Last edited by pherthyl; 22nd May 2008 at 02:38.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Copying Vector Images to the Windows Clipboard

    Probably the easiest solution would be to export to pdf and then convert it to postscript. There is a good chance M$ cra... apps will handle that.

  3. #3
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Copying Vector Images to the Windows Clipboard

    Hmm, good idea, I will give that a try. I hate going from the joy of Qt to the hell of Windows API...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Copying Vector Images to the Windows Clipboard

    It's not Windows API here that is a problem, it is the point of view of Micro$oft people what to consider a standard (hell... SVG can't be a standard because it wasn't developed in Microsoft, right?).

  5. #5
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Copying Vector Images to the Windows Clipboard

    Yup. How nice of a world it would be if I could just shove SVG onto the clipboard and have apps handle that. Not like SVG is a hard format to support these days..

    It seems to get this to work I have four options:

    1. Somehow render my graphicsview using GDI+ commands, which can then be saved as an enhanced metafile. That will probably require me to create a custom paintdevice, which I'm not clear on yet.

    2. Export SVG/PDF/PS and find a converter that actually works (difficult!), then copy the converted format to the clipboard.

    3. Copy an OLE object. No idea how to approach this yet, but this is how Word/Excel integration works.

    4. Use ActiveQt to create an ActiveX server which can then be inserted into word as Insert Object. This is not as desireable, as I want it to work with the regular clipboard.

Similar Threads

  1. Copying contents of QTableView cell to clipboard
    By Conel in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2006, 15:50

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.