Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Custom tooltip Tooltip in chartview



  • I have set a custom tooltip using the code

        ChartView {
            id: chart
            anchors.fill: parent
            antialiasing: true
            ValueAxis {
                id: axisY
                tickCount: 3
            }
            DateTimeAxis{
                   id: xTime
                   gridVisible: false
               }
            ToolTip {
                id: id_toolTip
                contentItem: Text{
                    color: "#21be2b"
                }
                background: Rectangle {
                        border.color: "#21be2b"
                    }
    
            }
            SplineSeries{
                id: chartseries
                pointsVisible: true
                pointLabelsVisible: false
                useOpenGL: true
                axisX: xTime
                axisY: axisY
                onClicked: {
                    id_toolTip.show("dd")
                 }
            }
    
        }
    

    It gives an error "TypeError: Property 'show' of object QQuickToolTip(0x37275d0) is not a function" when I click on the graph ..
    But below mentioned code snippets work.

       chart.ToolTip.show("dd")
    

    But I need custom tooltip



  • @Refi
    Try this:

     ChartView {
            id: chart
            ...
            ToolTip {
                id: tip
                contentItem: Text{
                    color: "#21be2b"
                    text: tip.text
                }
    
                background: Rectangle {
                     color: "yellow"
                    border.color: "red"
                }
            }
            LineSeries {
                 ...
                onClicked: {
                    tip.text = "dd"
                    tip.visible = true
                 }
            }
        }
    

    0_1534827119604_149be339-8a48-48e2-9917-36304330e4dd-image.png


Log in to reply