QT5.12.3 SwipeView enum Forms

40 Views Asked by At

Hi i want to add enum to identify my forms for the SwipeView.currentIndex... But my enum can't be found.

import QtQuick 2.12
import QtQuick.Controls 2.5

ApplicationWindow {
    id: window
    visible: true
    width: 640
    height: 480

    enum FormsEnum
    {
        InitForm=0,
        MainMenuForm=1
    }

    SwipeView {
        id: swipeView
        anchors.fill: parent
        currentIndex:FormsEnum.MainMenuForm


        Init {
            id: init
        }

        MainMenu {
            id: mainMenu
        }
    }
}

Can anybody help me ????

1

There are 1 best solutions below

2
On

In order to make it work you have to create a new qml for example Forms.qml:

import QtQuick 2.0
Item {
    enum FormsEnum
    {
        InitForm=0,
        MainMenuForm=1
    }
}

Then on your qml, you can use:

currentIndex: Forms.FormsEnum.MainMenuForm