首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在qml中使用SwipeView事件?

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

Stack Overflow用户
提问于 2018-03-24 05:26:14
回答 1查看 1.2K关注 0票数 0

我已经创建了一个新的qt快速控制项目,2 .It默认有一个SwipeView

现在我想使用onIndexChanged事件的SwipeView,但我得到了一个错误

代码语言:javascript
复制
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“

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-24 05:45:07

SwipeView没有index这样的属性。你可能是说currentIndex

代码语言:javascript
复制
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3

SwipeView {
    // ...
    onCurrentIndexChanged: {
        console.log(currentIndex)
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49461540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档