I have a nested Item where I want to declare an enum. How can I access the enum from the parent Item? I dont want to declare the enum in the outer Item, because it belongs to the nested/inner Item. I tried several things and the Docs dont show nested examples either.
// main.qml
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
MyItem {
id: myItem
enumValue: // ???
}
}
// MyItem.qml
import QtQuick 2.15
Item {
Component.onCompleted: console.log(nestedItem.MyEnum.First) // Cannot read property 'First' of undefined
Component.onCompleted: console.log(MyItem.MyEnum.First) // Cannot read property 'First' of undefined
Component.onCompleted: console.log(MyEnum.First) // MyEnum is not defined
Component.onCompleted: console.log(MyItem.First) // undefined
Item {
id: nestedItem
property int enumValue
enum MyEnum {
First,
Second,
Third
}
}
}
{ ... }scope it is declared in? This looks very similar. How about you describe the ultimate goal you are trying to achieve? On another note, do not overuse tags; are you workingqt6(as you should be) or are you still stuck onqt5?