[solved] QML Button Element - how to change background color?
-
wrote on 9 Dec 2011, 22:14 last edited by
hello!
i'm using standard Button Element and i need to change background color to something else than usual or inverted. let's say, how to change button color to green or red?
-
wrote on 9 Dec 2011, 23:32 last edited by
I'm not sure which "standard Button Element" you mean but if a Rectangle includes a MouseArea with an "id: ma" then something like this works to alternate the background when clicked...
@gradient: Gradient {
GradientStop { position: 0.0; color: ma.pressed ? "#0F0F0F" : "#2F2F2F" }
GradientStop { position: 1.0; color: ma.pressed ? "#2F2F2F" : "#0F0F0F" }
}@ -
wrote on 10 Dec 2011, 07:11 last edited by
I mean button element from qt-components http://doc.qt.nokia.com/qt-components-symbian/qml-button.html
Button built on rectangle is not an option, unfortunately
-
wrote on 10 Dec 2011, 07:41 last edited by
Hello,
Button element uses a BorderImage, not a Rectangle with gradient( http://qt.gitorious.org/qt-components/qt-components/blobs/master/src/symbian/Button.qml ). So I think it is not possible to change color.
-
wrote on 10 Dec 2011, 08:25 last edited by
eventually found solution!
@
Button {
// ... some needed design stuff
platformStyle: ButtonStyle {
background: "image://theme/color18-meegotouch-button-accent-background"
pressedBackground: "image://theme/color18-meegotouch-button-accent-background-pressed"
}
}
@it is also possible to make theme and other properties dynamically defined, but for me it was eniugh to have hardcoded value.
some more reading is here: http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-buttonstyle.html
1/5