Button isn't changing it's color.
-
I want to create simple login screen. I set button's background and colors dempending on it's state but when i click on it I can see the red color only for a while and later it changes to deafult windows button. I tried to change highlighted, and flat property but it doesn't help. How to fix it?
Button { id: button Layout.fillWidth: true Layout.fillHeight: true text: "A Special Button" flat: true highlighted: false background: Rectangle { Layout.fillWidth: true implicitHeight: 40 color: button.down ? "red" : (parent.hovered ? "red" : "purple") border.color: "#000101" border.width: 1 radius: 4 } }How it looks like: when pressed:

-
Tried the same example. It is working as expected from your code. May be try with simple sample & identify the issue with your code. May be something else is modified somewhere else.
-
Tried the same example. It is working as expected from your code. May be try with simple sample & identify the issue with your code. May be something else is modified somewhere else.
I've tried to rewrite my code for button in separate project and result is still the same as earlier, when button is pressed I can see result the same as on the picture above. Any ideas?
import QtQuick import QtQuick.Controls Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Button{ id: button anchors.fill: parent text: "click me" flat: true highlighted: false background: Rectangle { anchors.fill: parent color: button.down ? "red" : (parent.hovered ? "red" : "purple") } } } -
I've tried to rewrite my code for button in separate project and result is still the same as earlier, when button is pressed I can see result the same as on the picture above. Any ideas?
import QtQuick import QtQuick.Controls Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Button{ id: button anchors.fill: parent text: "click me" flat: true highlighted: false background: Rectangle { anchors.fill: parent color: button.down ? "red" : (parent.hovered ? "red" : "purple") } } }@Antek832
Can you try with simple statement like this first ?
color: button.down ? "red" :: "purple")What is the result of this ?
Which version of Qt ?