How to prevent manual scrolling of a page in SwipeView

How to prevent page scrolling in SwipeView? I would like to scroll through the current index just by interacting with the buttons. How can i achieve this? 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
    }    
}
+4
source share
1 answer

A property has recently been added interactiveand will be available in Qt 5.8 alpha.

If you cannot use 5.8 and know that the type contentItemis Flickable(it is currently intended for all inline styles), you can set its property interactiveto false:

Component.onCompleted: contentItem.interactive = false
+10
source

Source: https://habr.com/ru/post/1660895/


All Articles