Qml ChartView BarSeries извлекает положение мыши по событию Hovered - PullRequest
1 голос
/ 05 февраля 2020

Я хочу получить положение мыши, когда наведен какой-либо бар, но я не смог достичь. Вот мой код qml. На самом деле, я хочу показать текст, который говорит процентное значение навесной панели рядом с указателем мыши.

ChartView {

    property int hovered_bar_idx    :   -1

    anchors {
        left        :   parent.left
        right       :   parent.right
        rightMargin :   10
        bottom      :   parent.bottom
    }

    id              :   chart
    height          :   450
    title           :   "Staves Statuses"
    legend.alignment:   Qt.AlignBottom
    antialiasing    :   true
    backgroundColor :   "black"
    legend.visible  :   false

    BarSeries {
        id      :   mySeries
        barWidth:   0.85
        axisY   :   ValueAxis { max :   1.0;    min :   0.0; }
        axisX   :   BarCategoryAxis {
            id                  :   axis_x;
            categories          :   sys_hardware_display.categories;
            gridVisible         :   false
        }
        onHovered   :   {
            console.log( "s : " + status + " idx : " + index )

            // I want to retrieve position of mouse here.
        }

        BarSet  {
            id          :   stave_values
            label       :   "Staves"
            color       :   "#00FF00"
            borderWidth :   0
        }
    }
}
...