Adding behavior prevents color change of rectangle
Solved
QML and Qt Quick
-
I have a simple rectangle (below) whose color depends on a function. It works great, changing between 3 colors depending on properties of the overall item.
In order to ease the transition between colors I added a behavior as shown below. However, once I add the behavior the color is frozen (does not change) when the variables change, and no error is shown.
What is wrong?
Rectangle { id: rectItemBackground color: backgroundColor() implicitWidth: parent.width -rectRightItemBackground.width/2 implicitHeight: itemHeightByDepth(_depth) Behavior on color { NumberAnimation { duration: 1000 } } } function backgroundColor() { if (_selected) return gui.colorRGBString(GUIConstants.EColorElement_BackgroundSelected); if (_onSelectedPath) return gui.colorRGBString(GUIConstants.EColorElement_BackgroundPartialSelected); return gui.colorRGBString(GUIConstants.EColorElement_Background); }