[Interest] Binding::restoreMode buyers guide
Ulf Hermann
ulf.hermann at qt.io
Thu Oct 21 15:51:49 CEST 2021
> The question is all about QtQml 2.15 Binding type. The infamous missing
> unexported `restoreMode` property sure makes our lifes slightly harder
> than it should be (by generating warnings if left out); but when it
> comes to choosing an appropriate value for it -- I am totally lost.
The short story is: Always set it to RestoreBindingOrValue and adapt
your code as appropriate. All the other options are hacks introduced for
backwards compatibility.
In previous versions of Qt, there was no restoreMode and the behavior
was broken. Therefore we first introduced a switch you can use to opt
into the sane behavior and then made the sane behavior the default. You
can still explicitly select the insane behavior, but don't.
> Note that documentation doesn't come with any examples for restoreMode.
Because you shouldn't use it anymore.
> Also, any reason as to why Binding is `setValue(const QJSValue &)`, but
> QQuickPropertyAction is `setValue(const QVariant &v)`? I mean, QJSValue vs
> QVariant differences.
This is also a historical artifact. We've changed the type as a fix for
QTBUG-78943 . Since
https://codereview.qt-project.org/c/qt/qtdeclarative/+/305210 that "fix"
may be obsolete as we don't magically convert strings to colors anymore.
best regards,
Ulf
More information about the Interest
mailing list