[Interest] Function overload and QML
Federico Buti
bacarozzo at gmail.com
Mon Feb 16 13:09:45 CET 2015
Hi list.
I've made an intensive use of INVOKABLE/SLOT functions in QML and I've
never encounted any problem. Up until now.
I'm sure that function overloading works properly since I've used it a lot
(also the related commit can be found here
<https://qt.gitorious.org/qt/tmartsums-qt/commit/1d7b672fd46abab51a0124ad19aad18e5d14f1a8>).
However, I've noticed a strange behaviour by working with the
ArrayDataModel available here <https://github.com/dridk/ArrayDataModel>.
I've registered an instance of the model as a context property in the usual
way:
ArrayDataModel model;
engine.rootContext()->setContextProperty("model", &model);
Then in QML I've inserted a call to a SLOT in this way:
Button {
text: "click me!"
onClicked: {
model.insert(model.size(), "Item " + (model.size() + 1));
}
}
Theoretically, the method to be invoked by the runtime should be
void insert (int i, const QVariant &value);
However, if I exchange position of overloaded functions, i.e. if I write
the header as
ββ
Q_SLOT void insert (int i, const QVariant &value);
Q_SLOT void insert (int i, const QVariantList &values);
instead of the original
Q_SLOT void insert (int i, const QVariantList &values);
Q_SLOT void insert (int i, const QVariant &value);
the function which is called is (wrongly)
Q_SLOT void insert (int i, const QVariantList &values);
βIs this
β a BUG, an intended behaviour, a specific conversion JS <--> C++, e.g. the
parameter is seen as a single-item-array and made match with the wrong
overload? Or something else I cannot understand? :)
Thanks in advance for any insight,
F.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150216/5a527368/attachment.html>
More information about the Interest
mailing list