import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
Rectangle {
    id: container
    width: 640
    height: 360
    StackLayout {
        id: layout
        width: parent.width - 120
        height: 300
        anchors.top: parent.top
        anchors.topMargin: 6
        anchors.horizontalCenter: parent.horizontalCenter
        currentIndex: count - 1
        Rectangle {
            color: 'teal'
            implicitWidth: 200
            implicitHeight: 200
        }
        Rectangle {
            color: 'plum'
            implicitWidth: 300
            implicitHeight: 200
        }
        Rectangle {
            color: 'red'
            implicitWidth: 300
            implicitHeight: 200
        }
        Rectangle {
            color: 'blue'
            implicitWidth: 300
            implicitHeight: 200
        }
        Rectangle {
            color: 'green'
            implicitWidth: 300
            implicitHeight: 200
        }
    }
    Button {
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: layout.bottom
        anchors.topMargin: 6
        text: "Prev"
        onClicked:{
            if(layout.currentIndex == 0)
                layout.currentIndex = layout.count-1
            else {
                layout.currentIndex --
            }
        }
    }
}