2012-09-03 51 views
1

我注意到Qt5中有一個新的DropArea組件。我試圖從Finder中拖動一個文件(Mac),但只有onEntered方法被調用。QML DropArea接受外部阻力

import QtQuick 2.0 

Rectangle { 
    id: background; 
    color: "white"; 
    width: 300; 
    height: 300; 

    DropArea { 
     id: dropArea; 
     anchors.fill: parent; 
     onEntered: { 
      background.color = "gray"; 
      drag.accept (Qt.CopyAction); 
      console.log("onEntered"); 
     } 
     onDropped: { 
      console.log ("onDropped"); 
     } 
     onExited: { 
      bckground.color = "white"; 
      console.log ("onExited"); 
     } 
    } 
} 

這裏是窗口創建代碼:

int main(int argc, char *argv[]) 
{ 
    QApplication a(argc, argv); 

    QQuickView qmlView; 
    qmlView.setGeometry(0, 200, 600, 400); 
    qmlView.setResizeMode (QQuickView::SizeRootObjectToView); 
    qmlView.setSource(QUrl::fromLocalFile("/Users/ivann/Projects/QtGuiTestApp/testView.qml")); 
    qmlView.show(); 

    return a.exec(); 
} 

我缺少的東西?

+0

qt版本是5.0.0 beta 1 –

+0

也許它可以幫助你[鏈接](http://lists.qt.nokia.com/pipermail/qt-qml/2011-December/003335.html) –

+0

@aleks_misyuk謝謝。不幸的是,這是關於本地拖放。 –

回答

2

正如在chebum附帶的鏈接所述,該功能在本文撰寫時並未在任何平臺上得到QtQuick的支持。

只發佈讓它知道未來的讀者。