【问题标题】:How to prevent page manual swiping in SwipeView如何防止在 SwipeView 中手动滑动页面
【发布时间】:2016-11-16 05:50:40
【问题描述】:

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
    }    
}

【问题讨论】:

    标签: qt qml qtquick2 qtquickcontrols2


    【解决方案1】:

    interactive 属性 was added recently,将在 Qt 5.8 alpha 中提供。

    如果您不能使用 5.8,并且您知道 contentItem 的类型是 Flickable(目前适用于所有内置样式),则可以将其 interactive 属性设置为 @ 987654328@:

    Component.onCompleted: contentItem.interactive = false
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多