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 鼠标悬停事件在TableView的标题中不起作用_Qt_Qml_Tableview - Fatal编程技术网

Qt 鼠标悬停事件在TableView的标题中不起作用

Qt 鼠标悬停事件在TableView的标题中不起作用,qt,qml,tableview,Qt,Qml,Tableview,这里也有类似的问题 我想在鼠标悬停时突出显示标题。但是,headerDelegate中的行为很奇怪 headerDelegate: Rectangle { height:30 MouseArea{ hoverEnabled: true anchors.fill: parent onPressed: { console.debug("This will not be printed") }

这里也有类似的问题

我想在鼠标悬停时突出显示标题。但是,
headerDelegate
中的行为很奇怪

headerDelegate: Rectangle {
    height:30
    MouseArea{
        hoverEnabled: true
        anchors.fill: parent

        onPressed: {
            console.debug("This will not be printed")
        }

        onEntered: {
            console.debug("Will print on pressed event")
        }

        onExited: {
            console.debug("Will print on released event")
        }
    }
}

悬停在上方不会触发任何事件。

悬停和其他状态由标头委托中的
styleData
组件处理

如果您想知道悬停何时改变,请将
样式数据
的不同信号(
onPressed
oncontaininsmousechanged
等)连接到函数

例如:

headerDelegate: Rectangle {
        height:30
        color: "red"
        Connections {
            target: styleData
            onPressedChanged: {
                console.debug("PRESSED:  "+ styleData.column + " " + styleData.pressed)
            }

            onContainsMouseChanged: {
                if (styleData.containsMouse)
                    console.debug("The mouse is hover the header of column " + styleData.column)
                else
                    console.debug("The mouse is leaving the header of column " + styleData.column)
            }
        }
    }

在这个问题中,C++标签是不必要的。它在
headerDelegate
中运行良好。我也想在
rowDelegate
中使用此方法。但是
onContainsMouseChanged
rowDelegate
中不起作用,这里讨论的是管理
rowDelegate
中的事件。我想知道是否可以使用
连接
方法