1 Star 2 Fork 0

toby20130333/QMLDragDrop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mainview.qml 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
toby20130333 提交于 2015-06-01 23:03 . add new qml file
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import org.example.io 1.0
import "./dragdrop.js" as DropJs
ApplicationWindow {
title: qsTr("Hello World")
width: 400
height: 680
visible: true
GridView {
id: listView
width: parent.width-10
height: parent.height
cellHeight: 130
cellWidth: cellHeight
anchors.horizontalCenter: parent.horizontalCenter
property int dragItemIndex: -1
property bool isCurrentItem: false
model: ListModel {
id:lstModel
Component.onCompleted: {
for (var i = 1; i < 10; ++i) {
var tmp = 1180140+i-1;
}
//this is a question ,and you can use abouslute path
var json = readDocument("qrc:/drop.json");
var obj = DropJs.changeToJsonObject(json);
if(typeof obj =="object"){
var itemObj = obj.itemarry;
console.log("plObj length :"+obj);
for(var j=0;j<obj.length;j++)
{
if(typeof obj[j] == "object")
{
lstModel.append(obj[j]);
}
}
}
}
}
delegate: DragAndDropItem{
width: 120
height: 120
radius: 5
everyModels: itemarry
// display: value
// imgurl: url
border.width: 1
border.color: rodmColor()
color: "gray"//rodmColor()
entercolor: "#00ffcc"//rodmColor()
exitcolor:"gray" //rodmColor()
onDestorySelf: {
console.log("please destory it myself");
destoryItem(index);
}
onAddSomeObj: {
//addobj(obj);
}
function destoryItem(index){
lstModel.remove(index);
}
Component.onCompleted: {
// var obj = {"display":value,"imgurl":url};
// addobj(obj);
}
}
removeDisplaced: Transition {
NumberAnimation { properties: "x,y"; duration: 800 }
}
addDisplaced: Transition {
NumberAnimation { properties: "x,y"; duration: 500 }
}
}
Component.onCompleted: {
}
FileIO {
id: io
}
function readDocument(fileUrl) {
io.source = fileUrl
io.read();
return io.text;
}
//also get color by using Math.random();
function rodmColor(){
var str = "0123456789abcdef";
var t = "#";
for(var j=0;j<6;j++)
{
t = t+ str.charAt(Math.random()*str.length);
}
return t;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/duoduozhijiao/QMLDragDrop.git
[email protected]:duoduozhijiao/QMLDragDrop.git
duoduozhijiao
QMLDragDrop
QMLDragDrop
master

搜索帮助