Results 1 to 12 of 12

Thread: Copy-Paste files

  1. #1
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Copy-Paste files

    Hi all,
    I would like to copy some files in to Windows clipboard (if it's the clipboard...) like
    copying text with QClipboard. So then I can paste using normal Windows "Paste" command.
    Is that possible?

    thanks in advance

  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: Copy-Paste files

    Yes, just use an appropriate mime-type for your data. As far as I remember file paths can be encoded using text/url-list mime. But it's more likely that you want to store the object and not the file path itself...

  3. #3
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy-Paste files

    Yes, this is my case. I want to copy the entire file content like when someone does Copy and Paste from the file system. Can I do that from a QT Application?
    thanks

  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: Copy-Paste files

    I already answered your question.

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy-Paste files

    This might help you

  6. #6
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy-Paste files

    thanks,
    I thought there was a way using QT Clipboard, in a way that would be multiplatform.
    I found
    void QClipboard::setMimeData
    but I don't really know how to use it.
    Basically in my app I want to search for particular files and copy them in the clipboard(the entire file, not the file name). So then when I use "Paste" in the Operating system it will copy exactly those files.

    bye

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy-Paste files

    Just check the link I gave above.
    And as others said, u will need to set the proper format and data in the clipboard. Browse a little.

  8. #8
    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: Copy-Paste files

    Quote Originally Posted by Lele View Post
    (the entire file, not the file name).
    It's not the way it works. You copy file paths and then the target handles the paste (or drop as the mechanism is similar) and performs the copy. At least it works perfectly under KDE If you use local files or http/ftp Windows Explorer should handle it as well. As for other apps - it's up to them.

  9. #9
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Copy-Paste files

    I tried with:

    Qt Code:
    1. QMimeData* myFile= new QMimeData();
    2. myFile->setData("text/uri-list", "file:///C:/test80.png");
    3. clipboard->setMimeData(myFile);
    To copy to clipboard, switch view to plain text mode 

    But it doesn't seem to work.
    Any idea?

    thanks

  10. #10
    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: Copy-Paste files

    Where did you try to paste the file?

  11. #11
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy-Paste files

    in a normal window, but after my setData the "Paste" command was disabled.
    I guess something wrong with the Mime format, I'll investigate more

  12. #12
    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: Copy-Paste files

    "Normal window" meaning...? The desktop? Try copying from the desktop and pasting in a Qt app and see what mime it uses.

Similar Threads

  1. using cut(), copy(), paste()
    By systemz89 in forum Newbie
    Replies: 5
    Last Post: 18th December 2007, 14:47
  2. Mac: Copy Files Build Phase and qmake...
    By kuwan in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2007, 20:59
  3. Replies: 5
    Last Post: 22nd September 2006, 08:04
  4. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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.