Trying to use enum in QML. But the code does not work, the window is empty.
Application Output:
13:07:20 am: Starting X: \ QtPrograms \ build-EnumTest-Desktop-Debug \ debug \ EnumTest ... QML debugging is enabled. Only use this in a safe environment. qrc: /main.qml: 20: ReferenceError: main is not defined qrc: /main.qml: 18: ReferenceError: main is not defined
main.qml
import QtQuick 2.9 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Text { id: name enum TextType { Normal, Heading } property int textType: main.TextType.Normal text: textType === main.TextType.Normal ? "Normal" : "Heading" } }
main? It is not defined anywhere, and qt you naturally swear at it. First try to equate the type to zero and check if the Bearded Beaver will work