Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent page manual swiping in SwipeView

How to prevent page manual swiping in SwipeView? I would like to swipe current index just by interaction with buttons. How can I achieve that? Here is my QML code:

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
    }    
}
like image 431
Ruslan Skaldin Avatar asked Nov 16 '16 05:11

Ruslan Skaldin


Video Answer


1 Answers

An interactive property was added recently, and will be available in the Qt 5.8 alpha.

If you can't use 5.8, and you know that the type of the contentItem is a Flickable (which it currently is for all built-in styles), you can set its interactive property to false:

Component.onCompleted: contentItem.interactive = false
like image 126
Mitch Avatar answered Oct 17 '22 13:10

Mitch