[Interest] How to change button color in QML?
Mitch Curtis
mitch.curtis at qt.io
Mon Nov 26 15:17:08 CET 2018
First step would be to remove the MouseArea completely. Then, use the "hovered" property that Button inherits from Control:
Material.foreground: btnOK.hovered ? Material.Red : Material.Grey
(Untested)
> -----Original Message-----
> From: Interest <interest-bounces at lists.qt-project.org> On Behalf Of
> Minzhang He
> Sent: Wednesday, 21 November 2018 2:46 AM
> To: interest at qt-project.org
> Subject: [Interest] How to change button color in QML?
>
> I just started using and like QtQuick.Controls 2.
>
> I want change button Material color in QML.
> this is my QML code:
> Button {
> id: btnOK
> x: 248
> y: 208
> text: qsTr("确认")
> Material.foreground: Material.primary
> Material.background: Material.Dark
> MouseArea{
> anchors.fill: parent
> hoverEnabled: true
> onEntered: {
> //this is want to change Material code:
> //btnOK.Material.foreground = ???
> //btnOK.Material.background = ???
> }
> }
> }
> Can you help me?
More information about the Interest
mailing list