Override onPropertyChanged in inherited
-
Hi all,
I have a specialized SpinBox in a .qml in which I implemented a default onValueModified:
# MySpinBox.qml SpinBox { ... onValueModified: { print("modified in Base") } }Now I use this in my QML:
MySpinBox { onValueModified: { print("modified in inherited") } }My problem is that I get the two messages printed. I thought that "on property changed" will be overriden in the inherited class. This happens like this for functions.
How can I manage so that only the code in the inherited implementation will be executed ?
Thank you
-
Hi all,
I have a specialized SpinBox in a .qml in which I implemented a default onValueModified:
# MySpinBox.qml SpinBox { ... onValueModified: { print("modified in Base") } }Now I use this in my QML:
MySpinBox { onValueModified: { print("modified in inherited") } }My problem is that I get the two messages printed. I thought that "on property changed" will be overriden in the inherited class. This happens like this for functions.
How can I manage so that only the code in the inherited implementation will be executed ?
Thank you
@dextermagnific said in Override onPropertyChanged in inherited:
SpinBox
- Can you please tell me why you want to call valueModified() signal from
SpinBox { }when you can directly use it fromMySpinBox { }?
To avoid your problem you can define your own signal and use it.
MySpinBox.qmlSpinBox { id: root signal valueChanged() onValueModified: { root.valueChanged(); } }And in
main.qmljust useonValueChangedMySpinBox { onValueChanged: { console.log("Value :: ", value) } } - Can you please tell me why you want to call valueModified() signal from