如何在qml中使用SwipeView的事件?

时间:2018-03-24 05:26:14

标签: qt events qml swipeview

我创建了一个qt快速控件的新项目2.默认情况下有SwipeView

现在我想使用onIndexChanged的{​​{1}}事件,但我收到了错误

SwipeView

错误

  

qrc:/main.qml:25无法分配给不存在的属性" onIndexChanged"

1 个答案:

答案 0 :(得分:2)

SwipeView没有index这样的属性。你可能意味着currentIndex

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3

SwipeView {
    // ...
    onCurrentIndexChanged: {
        console.log(currentIndex)
    }
}