Je suis débutante et je ne reçois pas comment appeler canvas.requestPaint() Mon QML, le code est ci-dessous:QML - Pas en mesure de canvas.requestPaint() d'une fonction
//myTab.qml
TabView {
id: tv
width: parent.width
height: parent.height
antialiasing: true
style: TabViewStyle {
frameOverlap: -1
tab: Rectangle {
color: "Transparent"
implicitWidth: text1.width + 50
implicitHeight: 20
radius: 2
smooth: true
Canvas {
id: canvas1
anchors.fill: parent
width: parent.width
height: parent.height
onPaint: {
styleData.selected ? drawTab(canvas1,"#0C3142") :
drawTab(canvas1,"Transparent") //Some custom JS function to draw a object
}
Text {
id: text1
height: parent.height
verticalAlignment: Text.AlignVCenter
anchors.left : parent.left
anchors.leftMargin: 15
text: styleData.title
color: "white"
}
}
}
frame: Rectangle {
width: parent.width
height: parent.height
color: "Transparent"
border.color:"white"
}
tabBar: Rectangle {
color: "Transparent"
anchors.fill: parent
}
}
Tab {
id: tab1
title: "Tab1"
}
Tab{
id: tab2
title: "Tab2"
}
onCurrentIndexChanged: {
console.log("index changed "+currentIndex)
canvas1.repaint() //ERRROR - not defind canvas1
}
}
Quand j'essaie d'utiliser dans onCurrentIndexChanged
, je reçois l'erreur suivante:
ReferenceError: canvas1 is not defined.
S'il vous plaît Suggest.
i ajouté un rafraîchissement du signal() et plus tard fait une connexion dans Canvas, mais j'ai obtenu "Connexions QML: Impossible d'attribuer à la propriété inexistante" onRefresh "" Erreur. – pra7
C'est exactement ce dont j'ai besoin .. j'ai utilisé la cible: canvas1 et c'est la raison pour laquelle cela n'a pas fonctionné .... Merci @derM – pra7