7

如何防止页面手动刷入SwipeView?我想通过与按钮交互来滑动当前索引。我怎样才能做到这一点?这是我的 QML 代码:

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import QtQuick.Controls.Material 2.0

ApplicationWindow {

    property int globalForJs: 10;

    id: mainWindow
    visible: true
    width: 1024
    height: 768
    color: '#ffffff'
    signal qmlSignal(string msg)

    TopPanel {
        id: topPanel1
    }

    SwipeView {
        id: view
        currentIndex: 0
        anchors.fill: parent

        Rectangle {
            id: firstPage
            color: "red"
        }

        Rectangle {
            id: secondPage
            color: "blue"
        }
    }


    BottomPanel {
        id: bottomPanel1
    }    
}
4

1 回答 1

13

最近添加了一个interactive属性,将在 Qt 5.8 alpha 中可用。

如果你不能使用 5.8,并且你知道 的类型contentItem是 a Flickable(它目前适用于所有内置样式),你可以将它的interactive属性设置为false

Component.onCompleted: contentItem.interactive = false
于 2016-11-16T08:56:26.600 回答