import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4

import QtQuick.Controls 2.3 as Control2

Item {
    id:rootItem
    signal signalClicked(string text)
    TreeView {
        id:treeFrame
        anchors.fill: parent
        headerVisible: false
        alternatingRowColors:false
        TableViewColumn {
            title: "名字"
            role: "title"
            width: 100
        }
        model: TreeModel
        onActivated: {
            console.log("clicked:::::::",TreeModel.data(index,1));
            if(TreeModel.hasChildren(index)){
                console.log("can expand or collese",isExpanded(index))
                if(isExpanded(index)){
                    collapse(index);
                }else{
                    expand(index);
                }
            }else{
                signalClicked(TreeModel.data(index));
            }
        }
        style: TreeViewStyle {
            textColor:"#FFFFFF"
            backgroundColor :"#282B33";
            alternateBackgroundColor:"#282B33"
            activateItemOnSingleClick:true
            itemDelegate:Item {
                id: itemId
                width: rootItem.width
                height: 30
                Text {
                    id: name
                    text: styleData.value
                    horizontalAlignment: Text.AlignLeft
                    verticalAlignment: Text.AlignVCenter
                    font.pixelSize: 14
                    color:   styleData.textColor
                    anchors.fill: parent
                }
            }
            handle: Item {
                implicitWidth: styleData.horizontal?26:14
                implicitHeight: styleData.horizontal?14:26
                Rectangle {
                    color: "#393D49"
                    anchors.fill: parent
                    anchors.topMargin: styleData.horizontal?1:6
                    anchors.leftMargin: styleData.horizontal?6:1
                    anchors.rightMargin: styleData.horizontal?6:1
                    anchors.bottomMargin: styleData.horizontal?1:6
                    radius: 6
                }
            }
            scrollBarBackground: Rectangle {
                implicitWidth: styleData.horizontal?26:14
                implicitHeight: styleData.horizontal?14:26
                color: "#141414" //styleData.horizontal
            }
            decrementControl:Item{

            }
            incrementControl:Item{
            }
            branchDelegate:Item{

            }
        }
    }
}


标签:Qt C++ Python



开发PC客户端,服务于金融行业 37091473(付费咨询)
沪ICP备14050191号 Copyright © 多多指教社区(群:312125701)
Tobyyi's QtQuick Example | Powered by NoderCMS