Open jackman0 opened 10 years ago
I ran the same code against Qt 5.1.1, and I get the same result. I also tried explicitly declaring the type of 'x' as an int, int16, int32, and int64. With the exception of int16 (not yet implemented), the output among all of these was similar.
Per the mailing list response:
Sorry for not providing a more timely response to your ticket, Andrew.
I'll have to spend some time looking at why the default Qt introspection capabilities are failing with that function, but my guess is that it is related to how there's some JavaScript-specific magic in its definition.
Meanwhile, there's an easy way to workaround the issue: define a function like this in your modelROList type:
function myget(i) { return modelROList.get(i) }
and call that from Go instead. This will be a standard function, and won't suffer from these anomalies.
As a reference, these are the method declarations in QQmlListModel:
Q_INVOKABLE void clear();
Q_INVOKABLE void remove(QQmlV4Function *args);
Q_INVOKABLE void append(QQmlV4Function *args);
Q_INVOKABLE void insert(QQmlV4Function *args);
Q_INVOKABLE QQmlV4Handle get(int index) const;
Q_INVOKABLE void set(int index, const QQmlV4Handle &);
Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
Q_INVOKABLE void move(int from, int to, int count);
Q_INVOKABLE void sync();
Hello Gustavo, whats the right way to call append to add new elements to the list model, im running into the same issue!? http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html#append-method
edit: current solution pasted to https://groups.google.com/forum/#!topic/go-qml/WCj373DO6qM
Yes, this is the same issue, and will be addressed once the general support for this is added.
Ok
I accidentally closed this, but I think it was pretty much in a closed (duplicate) status, anyway.
Duplicate of what?
Please refer to the following URL as the pertinent QML reference: http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html
My intent is to manipulate a QML TableView. The data model for the TableView is a ListModel. When attempting to do a simple fetch of a model row, I get a panic. Here is the relevant code:
The Go file:
The QML file:
Output:
I am using QML 5.3.1 as the TableView is not available in 5.0.3 (the recommended version on GitHub).
I tried looking for a model use of the Call() method in the repostory with parameters, but I just didn't find one.