Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2

Rectangle
{
    width
: 640
    height: 450

    ListModel
    {
        id: objmodel
        ListElement
        {
            name: "张飞"
        
}
        ListElement
        
{
            name
: "华佗"
        
}
        ListElement
        
{
            name
: "朱治"
        
}
        ListElement
        
{
            name
: "公孙度"
        
}
        ListElement
        
{
            name
: "袁本初"
        
}
        ListElement
        
{
            name
: "杨松"
        
}
    }

    Component
    
{
        id
: delegateItem
        Item
        {
            id: wrapper
            width: parent.width
            height: 30

            Text
            {
                id: coll
                text: name
                font.pointSize: 13
                color: wrapper.ListView.isCurrentItem? "red":"black"
            
}

            MouseArea
            
{
                id
: mousearea
                anchors.fill: parent
                onClicked:listview.currentIndex = index
;

                onMouseXChanged
:
                {
                    var pore = listview.indexAt(mousearea.mouseX + wrapper.x, mousearea.mouseY + wrapper.y)
;
                    if(index !== pore )
                    {
                        objmodel.move(index,pore,1)
                    
}
                }

                onMouseYChanged:
                
{
                    var pore = listview.indexAt(mousearea.mouseX + wrapper.x, mousearea.mouseY + wrapper.y);
                    if(index !== pore)
                    {
                        objmodel.move(index,pore,1)
                    
}
                }
            }
        }
    }

    ListView
    
{
        id
: listview
        width:240
        height:180
        anchors.centerIn: parent
        delegate: delegateItem
        model:objmodel
        interactive: false
        focus: true

        move: Transition
        {
            NumberAnimation { properties: "x,y"
; duration: 2100 }
        }
    }
}
posted on 2019-08-30 15:59 ccsdu2009 阅读(38) 评论(0)  编辑 收藏 引用 所属分类: QT编程

只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理