7

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
    }    
}
BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82
Ruslan Skaldin
  • 981
  • 16
  • 29

1 Answers1

13

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
Mitch
  • 23,716
  • 9
  • 83
  • 122