Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qmlscene crashed when hover in at a ScatterSeries point

qmlscene crashed when hover in at a ScatterSeries point

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 239 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gang Deng
    wrote on last edited by Gang Deng
    #1

    Dear All,
    What I want to do is change a point to red when move mouse into an ScatterSeries point, and recovery the point's when move mouse out of the point. To get it, I define an ScatterSeries with id:selectedPointer to show the red point. When mouse hover into an point, append the point to selectedPointer ; while clear selectedPointer when hover out the point.
    Here's a strange problem that qmlscene crashes when hover into a ScatterSeries point. I guess that when the selectedPointer is shown, the points lost focuse and call onHovered with state == false. It will crashes when call selectedPointer.clear() in this state. Is there any ideal of resolve this problem?

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtCharts 2.3
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        property var points_X:[1.51,1.57,2.0,2.55]
        property var points_Y: [2.51,3.57,4.0,4.55]
        ChartView{
            id: myChart
            anchors.fill: parent
    
    
            legend{
                visible: false
            }
    
            // line curve
            LineSeries{
                id: line
    
    
            }
    
            ScatterSeries{
                id: points
    
                onHovered:{
    
                    if (state === true){
                        console.log("hovered in : x:" + point.x + " y:" + point.y)
                        selectedPointer.clear()
                        selectedPointer.append(point.x,point.y)
                    }else{
                        console.log("hovered out : x:" + point.x + " y:" + point.y)
                        selectedPointer.clear()
    
                    }
    
                }
    
                onPressed:  {
    
                    selectedPointer.clear()
                    selectedPointer.append(point.x,point.y)
                }
    
            }
    
            ScatterSeries{
                id: selectedPointer
                color: "red"
            }
    
            Component.onCompleted:  {
                var index
                console.log("points_X:"+ points_X.length)
                for(index = 0;index < points_X.length;index++){
                    line.append(points_X[index],points_Y[index])
                    points.append(points_X[index],points_Y[index])
                    console.log("append : "+ points_X[index],points_Y[index])
    
                }
    
                selectedPointer.append(points_X[1],points_Y[1])
    
                myChart.axisX().max = 3
                myChart.axisY().max = 5
            }
        }
    }
    
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved