查看完整版本: [-- zhengtianzuo系列-QmlTextEdit接受拖放 --]

QTCN开发网 -> Qt代码秀 -> zhengtianzuo系列-QmlTextEdit接受拖放 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

zhengtianzuo 2017-10-20 11:27

zhengtianzuo系列-QmlTextEdit接受拖放

在TextEdit中增加DropArea

```
    TextEdit{
        id: textEdit
        height: 300
        width: parent.width
        DropArea{
            anchors.fill: parent
            onDropped: {
                if (drop.hasUrls){
                    console.debug("拖放了文件: " + drop.urls.length);
                    for(var i = 0; i < drop.urls.length; i++){
                        console.debug("文件: " + drop.urls);
                        textEdit.append("文件: " + drop.urls)
                    }
                }
                else if (drop.hasText){
                    console.debug("拖放了本文: " + drop.text.length);
                    console.debug("文本: " + drop.text);
                    textEdit.append("文本: " + drop.text)
                }
            }
        }
    }
```



需要完整代码请访问 QtQuickExamples

自强不吸 2017-10-20 14:10

big_mouse 2020-04-22 09:21


查看完整版本: [-- zhengtianzuo系列-QmlTextEdit接受拖放 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled