Behaviours with States

Michał 'rysiek' Woźniak rysiek at fwioo.pl
Wed Apr 17 21:51:47 UTC 2013


Hi there,

In my QML plasmoid I was tracking a bug related to using Behaviours 
with States, when I found this helpful documentation page:
http://qt-project.org/doc/qt-4.8/qml-behaviors-and-states.html

This solved it for me, or rather nudged me in the right direction. I 
have found another way of solving this problem - just explicitly 
define the default state:

states: [
         State {
             name: "GreenState"
             when: mouser.containsMouse

             PropertyChanges {
                 target: coloredRect
                 color: "green"
             }
         },
         State {
             name: ""

             PropertyChanges {
                 target: coloredRect
                 color: "red"
             }
         }
]

This does not require the rest of the QML app to be aware of the name 
of the new "default" state; nor does it require the default state 
conditions to be precisely defined (which sometimes might be a 
challenge, and besides opens the plasmoid for new, hard to track 
errors).

The empty name "" denotes the default base state anyway.

I have tested it in my plasmoid and it indeed works. I think it would 
be a good idea to out that in the docs.

-- 
Pozdrawiam
Michał "rysiek" Woźniak

Fundacja Wolnego i Otwartego Oprogramowania
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 316 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20130417/cdd0acba/attachment.sig>


More information about the Plasma-devel mailing list