2016-11-16 70 views
4

如何防止頁面手動在SwipeView中滑動?我想通過與按鈕交互來刷新當前索引。我怎樣才能做到這一點?這裏是我的QML代碼:如何防止頁面手動在SwipeView中滑動

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

回答

10

interactive財產was added recently,並將在Qt的5.8阿爾法可用。

如果您不能使用5.8的,你知道contentItem的類型是Flickable(這是目前所有內置樣式),您可以設置它的interactive屬性false

Component.onCompleted: contentItem.interactive = false 
相關問題