Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用QT Quick Control 2.0为TableView中的行指定边框颜色?_Qt_Qml_Tableview_Qtquickcontrols - Fatal编程技术网

如何使用QT Quick Control 2.0为TableView中的行指定边框颜色?

如何使用QT Quick Control 2.0为TableView中的行指定边框颜色?,qt,qml,tableview,qtquickcontrols,Qt,Qml,Tableview,Qtquickcontrols,表1 表2 Item { id: control TableView { id: table1 delegate: Rectangle { color: control.selected === row ? "pink" : "white"

表1

表2

            Item {
                id: control
                TableView {
                    id: table1
                    delegate: Rectangle {
                        color: control.selected === row ? "pink" : "white"
                        border.color: control.selected === row?"lightblue":"transparent"
                        border.width: 2
                        Text {
                            text: display
                            color: "black"
                        }

                    }
                }
            }

影响

在QtQuick Controls 1.0版上使用rowDelegate很容易实现。 我不知道在选择行时为行项目设置边框颜色。
似乎只能为一行中的每个项目设置边框颜色。

我最后用其他四个矩形做了:)
像这样:

    TableView{
        id :tableView
          headerDelegate:Rectangle{
                color : "transparent"
               Text
                {
                    text: styleData.value
                }
           }

       rowDelegate: Rectangle {
           color : styleData.selected ?  "pink" : "white"
           border.color: styleData.selected ?"lightblue":"transparent"
       }
       itemDelegate: Rectangle{
           color : "transparent"
           Text {
                color : "black"
                text: styleData.value
            }
       }

         style: TableViewStyle{
             backgroundColor : "transparent"

         }
    }
}
Rectangle { anchors.top: parent.top; height: item_table.borderWidth; width: parent.width; color: isSelect()?borderColor:"transparent"}
Rectangle { anchors.bottom: parent.bottom; height: item_table.borderWidth; width: parent.width;  color: isSelect()?borderColor:"transparent"}
Rectangle { anchors.left:  parent.left; height: parent.height; width: item_table.borderWidth; color: borderColor; visible: (isSelect()&&column === 0) }
Rectangle { anchors.right: parent.right; height: parent.height; width: item_table.borderWidth; color: borderColor; visible: (isSelect()&&column === tableView.columns - 1) }