qtqmlqt5states

Unable to use states with ApplicationWindow


Let's consider this code snippet:

ApplicationWindow
{
    /**/
    states: State {}
    /**/
}

When running the application, I get

Cannot assign to non-existent property "states"

When using

ApplicationWindow
{
    /**/
    Item { states: State {} }
    /**/
}

There is no error. Why can't I use states inside an ApplicationWindow?


Solution

  • I've just realized that ApplicationWindow inherits Window inherits QQuickWindow. Only types which inherit from Item have the states property.

    The workaround is to use StateGroup.

    Feel free to add a better solution ;)