我已经创建了一个新的qt快速控制项目,2 .It默认有一个SwipeView。
现在我想使用onIndexChanged事件的SwipeView,但我得到了一个错误
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)
}
}误差
qrc:/main.qml:25不能分配给不存在的属性"onIndexChanged“
发布于 2018-03-24 05:45:07
SwipeView没有index这样的属性。你可能是说currentIndex。
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
SwipeView {
// ...
onCurrentIndexChanged: {
console.log(currentIndex)
}
}https://stackoverflow.com/questions/49461540
复制相似问题