Thanks for the history lesson, I appreciate it!
 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.

 
Then, by all means, let's state that explicitly in the docs, loud and clear!
Currently the description is kinda confusing: it mentions that the defaults
were changing over time; there are several one-sentence paragraphs, which are
not very convenient to comprehend; and finally it doesn't imply "saneness" of
options in any way.
 
Also, without looking at source code, there's no way to understand, e.g. whether
Binding.RestoreBinding mode re-evaluates the binding as a part of restoration
process. I guess it should be the same as assigning Qt.binding(() => ...) _expression_,
in which case it wouldn't hurt to also mention that in docs.
 
As to should or shouldn't one be using them... As they say, for better or
worse developers don't get to choose how users gonna interact with their
product (API). If there's a workflow, especially an officially documented
one, then the documentation better be a good one, right?
 
 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.

That... sounds horrifying. Good to see it being fixed though!
 
--
ivan (@ratijas)
 
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to