Button property undefined
-
wrote on 29 Jan 2024, 19:50 last edited by
Hi,
I couldn't find any information inside documentation regarding this behavior.
property bool enabled is overridden inside button.
Dummy1 is set to disabled and looks like it is disabled but all events and other visual styles are working on it.
Dummy2 is working fine.
Is this bug, undefined behavior or it is working as expected?
Commenting out "property bool enabled" make Dummy1 work as expected (disabled)//main.qml import QtQuick 2.9 import QtQuick.Controls 2.5 import QtQuick.Controls.Material 2.12 ApplicationWindow { visible: true width: 800; height: 600 ButtonProblem { id: button1 enabled: false text: "Dummy1" } ButtonProblem { id: button2 y: 50 enabled: true text: "Dummy2" } } //ButtonProblem.qml import QtQuick 2.9 import QtQuick.Controls 2.5 Button { property bool enabled onPressed: { console.log("onPressed") } onClicked: { console.log("onClicked") } }
As you can see it can be pressed:
Additional info:
QQuickStyle::setStyle("Material");
Qt5.12.12 -
Hi,
I couldn't find any information inside documentation regarding this behavior.
property bool enabled is overridden inside button.
Dummy1 is set to disabled and looks like it is disabled but all events and other visual styles are working on it.
Dummy2 is working fine.
Is this bug, undefined behavior or it is working as expected?
Commenting out "property bool enabled" make Dummy1 work as expected (disabled)//main.qml import QtQuick 2.9 import QtQuick.Controls 2.5 import QtQuick.Controls.Material 2.12 ApplicationWindow { visible: true width: 800; height: 600 ButtonProblem { id: button1 enabled: false text: "Dummy1" } ButtonProblem { id: button2 y: 50 enabled: true text: "Dummy2" } } //ButtonProblem.qml import QtQuick 2.9 import QtQuick.Controls 2.5 Button { property bool enabled onPressed: { console.log("onPressed") } onClicked: { console.log("onClicked") } }
As you can see it can be pressed:
Additional info:
QQuickStyle::setStyle("Material");
Qt5.12.12wrote on 29 Jan 2024, 20:09 last edited by@nixako2186 said in Button property undefined:
enabled
enabled is a property of Button. Why do you want to use it as a local property?
-
@nixako2186 said in Button property undefined:
enabled
enabled is a property of Button. Why do you want to use it as a local property?
wrote on 29 Jan 2024, 20:23 last edited by@JoeCFD
I was experimenting with properties and their behavior and I just did it. I wanted to understand what is happening.
As you can see it seems that this is somehow partially overridden. Visually it looks like disabled but functionally it works just fine.I know that this is property of Button but if it possible to override it then why not? Maybe it should be prevented by parser - final keyword on property inside Button.qml or at least described in documentation.
-
@JoeCFD
I was experimenting with properties and their behavior and I just did it. I wanted to understand what is happening.
As you can see it seems that this is somehow partially overridden. Visually it looks like disabled but functionally it works just fine.I know that this is property of Button but if it possible to override it then why not? Maybe it should be prevented by parser - final keyword on property inside Button.qml or at least described in documentation.
wrote on 29 Jan 2024, 21:24 last edited by JoeCFD@nixako2186 Since your code runs, this means you can override it. However, you may lose control over when your local enabled or the one defined in Button is used. Therefore, better never do it.
1/4