Problem dropping a file on ManWindow (Qt 5.4 mac)



  • i'm Using OS X 10.10.
    I have Problem dropping a file (from Finder) on ManWindow
    This problem exists in Qt 5.4 mac

    this is my code
    @void PhotoWindow::dragEnterEvent(QDragEnterEvent *event)
    {
    if (event->mimeData()->hasUrls())
    {
    event->acceptProposedAction();
    }
    }

    void PhotoWindow::dropEvent(QDropEvent *event)
    {
    foreach (const QUrl &url, event->mimeData()->urls())
    {
    PhotoAddress << url.toLocalFile();

        if(!PhotoAddress.isEmpty(&#41;&#41;
        {
            pe=true;
    
            this->ProcessingPhoto(&#41;;
        }
    }
    

    }@

    But return me something like this : /.file/id=6571367.1965329

    this problem even exists in Qt Creator
    When dropping a file (from Finder) on Qt Creator.
    !http://sd.uploads.im/xOMHk.png!

    This should be a bug in Qt 5.4 mac!



  • I ran into this too. It is a problem with Yosemite; I didn't have a problem with Mountain Lion.

    You need to modify the file 'qtbase/src/platformsupport/clipboard/qmacmime.mm' and recompile Qt (assuming you have the source for Qt).

    The complete function is here including the changes (two lines). It starts on line number 608

    @
    QVariant QMacPasteboardMimeFileUri::convertToMime(const QString &mime, QList<QByteArray> data, QString flav)
    {
    if (!canConvert(mime, flav))
    return QVariant();
    QList<QVariant> ret;
    for (int i = 0; i < data.size(); ++i) {
    QUrl url = QUrl::fromEncoded(data.at(i));
    if (url.host().toLower() == QLatin1String("localhost"))
    url.setHost(QString());

         if (url.host().isEmpty() && url.path().startsWith(QLatin1String("/.file/id=")))
    

    url = QUrl::fromNSURL([url.toNSURL() filePathURL]);

        url.setPath(url.path().normalized(QString::NormalizationForm_C));
        ret.append(url);
    }
    return QVariant(ret);
    

    }
    @


Log in to reply
 

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