• 2572阅读
  • 2回复

zhengtianzuo系列-QmlTextEdit接受拖放 [复制链接]

上一主题 下一主题
离线zhengtianzuo
 

只看楼主 倒序阅读 楼主  发表于: 2017-10-20
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
博客地址: https://blog.csdn.net/zhengtianzuo06
Github: https://github.com/zhengtianzuo
个人产品: https://github.com/zhengtianzuo/Silk
产品网站: http://www.camelstudio.cn
离线自强不吸

只看该作者 1楼 发表于: 2017-10-20
自强不吸!
离线big_mouse

只看该作者 2楼 发表于: 2020-04-22
快速回复
限100 字节
 
上一个 下一个