I have created an new project of qt quick controls 2 .It have an SwipeView
as default.
Now I want to use onIndexChanged
event of SwipeView
but I got an error
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1 {
}
Page {
Label {
text: qsTr("Second page")
anchors.centerIn: parent
}
}
onIndexChanged: { //error is in this line
console.log(index)
}
}
Error
qrc:/main.qml:25 Cannot assign to non-existent property "onIndexChanged"
SwipeView
does not have such property as index
. You probably meant currentIndex
.
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
SwipeView {
// ...
onCurrentIndexChanged: {
console.log(currentIndex)
}
}