Qt 如何在qml中使用SwipeView的事件?
我已经创建了一个新的qt quick controls 2项目。它的默认设置是Qt 如何在qml中使用SwipeView的事件?,qt,events,qml,swipeview,Qt,Events,Qml,Swipeview,我已经创建了一个新的qt quick controls 2项目。它的默认设置是SwipeView 现在我想使用SwipeView的onIndexChanged事件,但我得到了一个错误 import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 SwipeView { id: swipeView anchors.fill: parent currentIndex: tabBar.cur
SwipeView
现在我想使用SwipeView的onIndexChanged
事件,但我得到了一个错误
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”
没有诸如索引
之类的属性。你的意思可能是currentIndex
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
SwipeView {
// ...
onCurrentIndexChanged: {
console.log(currentIndex)
}
}
没有诸如索引
之类的属性。你的意思可能是currentIndex
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
SwipeView {
// ...
onCurrentIndexChanged: {
console.log(currentIndex)
}
}