Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.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 QML如何将鼠标悬停与styleData.selected一起使用_Qt_Qml - Fatal编程技术网

Qt QML如何将鼠标悬停与styleData.selected一起使用

Qt QML如何将鼠标悬停与styleData.selected一起使用,qt,qml,Qt,Qml,我正在尝试为TableView中的行构建一个简单的委托。 我希望它在鼠标悬停时显示边框,在选中时留下边框。见下面的代码: Component { id: rowDelegate Item { height: 40 Rectangle { id: rowRectSel anchors.fill: parent color: "grey" radius: 2

我正在尝试为TableView中的行构建一个简单的委托。 我希望它在鼠标悬停时显示边框,在选中时留下边框。见下面的代码:

  Component
  {
    id: rowDelegate
    Item
    {
      height: 40

      Rectangle
      {
        id: rowRectSel
        anchors.fill: parent
        color: "grey"
        radius: 2
        opacity: 0.4
        border.width: 3;
        visible: styleData.selected
      }

      Rectangle
      {
        id: rowRect
        anchors.fill: parent
        color: "grey"
        radius: 2
        opacity: 0.4
        border.width: 1;
        visible: !styleData.selected
      }

      MouseArea
      {
        id: rowMouseA
        hoverEnabled: true
        anchors.fill: parent
        preventStealing: false
        propagateComposedEvents: true
        enabled: !styleData.selected
      }

      states:
      [
        State
        {
          name: "hover"
          when: rowMouseA.containsMouse
          PropertyChanges { target: rowRect; border.width: 2; }
        }
      ]
    }
问题是当MouseArea(rowMouseA)存在时,它不会显示rowRectSel-以某种方式阻止行更改styleData.selected属性。
如果我删除MouseArea或将enabled属性设置为false,则选中时rowRectSel将可见。

ist styleData定义在何处?在此情况下,它被称为“特殊属性”。可能重复