Results 1 to 6 of 6

Thread: QClipboard and Windows

  1. #1
    Join Date
    Apr 2007
    Location
    Italy
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QClipboard and Windows

    Hi all!
    I must prepare an application for Windows for copying files, it's some kind of "Advanced Paste".
    It should read a list of filepaths from the system clipboard (this filepaths are already in the clipboard using the windows buit-in Edit->Copy function from the file manager) and make a copy of those files using a series of rules that the user can specify.
    On linux it works perfectly, while in windows I have some problem. In linux when you issue the "Copy" command, you will find a simple list of paths in the clipboard. In windows I can't figure out what format is used, so I cannot identify the selected files.
    This is the section of code which takes the filepaths from the clipboard:
    Qt Code:
    1. ...
    2. QClipboard *clipboard=qApp->clipboard();
    3. qDebug()<<"The system clipboard contains:\n" <<clipboard->text();
    4. QString clipboard_text=clipboard->text();
    5. QStringList file_list=clipboard_text.split('\n',QString::SkipEmptyParts);
    6. ...
    To copy to clipboard, switch view to plain text mode 

    Under linux it works and gives me the content of the clipboard, on windows it says the clipboard is empty.
    Anyone can help?
    Sorry for Bad English!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QClipboard and Windows

    J-P Nurmi

  3. #3
    Join Date
    Apr 2007
    Location
    Italy
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QClipboard and Windows

    Quote Originally Posted by jpn View Post
    I already tried it.
    The urls() doesn't return anything because the clipboard format used by Windows for filepaths isn't standard (I guess you didn't expect that, don't you?). Windows uses some shitty format (application/x-qt-windows-mime;value="Shell IDList Array or something like that) and I don't understand how to use QWindowsMime which should override the problem. Now I'm trying to use directly the windows API to obtain a dump of the data saved in the clipboard and then I plan to extrapolate the filepaths from there. It's just tedious.
    Anyone got better ideas?
    Sorry for Bad English!

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QClipboard and Windows

    At least the drag and drop data from Windows Explorer contains "text/uri-list". I'd expected the clipboard data to follow same convention.
    J-P Nurmi

  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: QClipboard and Windows

    I dont think you are evaluating the mime data properly.
    I checked the Drop Site example in Qt Demo. When I drag and drop multiple files, I get
    Format -
    application/x-qt-windows-mime;value="Shell IDList Array"
    ...
    ...
    text/uri-list


    In the text/uri-list , in the contents part I see the list of file names.

    Please refer to the Drop Site example and see urself. May be clipboard does same thing. You need to iterate over the mime data like in the example.

  6. #6
    Join Date
    Apr 2007
    Location
    Italy
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QClipboard and Windows

    Ok I will give a try with that tutorial.
    However if I try to take "text/uri-list" data from the MimeData it returns empty string (even though I already selected and "copied" some files).

    EDIT:
    OMG I think I found the error. You were right, using urls() function return a url list of the selected files. The problem seems to be about some configuration option in the project file. I forgot to specifiy the qmakespec and the TARGET variable so basically I executed the same program over and over without modifying anything.
    This brings me to another question: Is there a GOOD Windows IDE compatible with QT, which supports project file creation and customization, and project building and debugging??
    I tried CodeBlocks but it doesn't work that well (I can't start the debug).
    Last edited by GodOfWar; 21st July 2008 at 09:44. Reason: updated contents
    Sorry for Bad English!

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.