Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to use states with ApplicationWindow

Tags:

qt

qt5

states

qml

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?

like image 867
marmistrz Avatar asked Aug 14 '15 11:08

marmistrz


1 Answers

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 ;)

like image 180
marmistrz Avatar answered Oct 09 '22 06:10

marmistrz