DragDrop and %



  • Hello,
    i want to drag Dir- and File-Names in my app.
    When i drag from explorer "dir#%.txt" i receive "dir%23%25.txt" ( i use event->mimeData()->text() )
    When i drag same file from my a QTableWidget in my app to another window in same app, i receive "dir#%25.txt"
    No problems with unicode like "Æ⊜滪" , but why with # and %?

    I now replace "%23" -> "#" and "%25" -> "%" but i think, that's not the best solution.
    Is there a better possibility to get the right characters?
    And, to get ALL replaced characters (not sure, if it's enough to replace these 2 ones)

    And..is there a spec about this? I searched about one hour, but did not find anything.


  • Qt Champions 2016

    @tomweb said:

    dir#%.txt

    Hi it seems to be normal URL encoding

    http://www.w3schools.com/tags/ref_urlencode.asp

    Did u look if
    QMimeData::urls()
    contains other file name?

    Maybe you can convert it back to "dir#%.txt"
    with
    QString QUrl::fromPercentEncoding(const QByteArray &input)
    or some of the other URL functions.



  • @mrjj
    Thank you, works.
    QList<QUrl> urlList = event->mimeData()->urls(); followed by QString f = urlList[urlNr].toString();
    has the same result.

    Regardles if i use mimeData()->text() or mimeData()->urls() i must use fromPercentEncoding
    now i use
    QString f = QUrl::fromPercentEncoding( urlList[urlNr].toString().toUtf8() );
    Have a nice Sunday


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.