Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.0.0 Beta 1
-
None
Description
The following minimal code triggers a warning inside QQuickItem::stackBefore although I cannot see anything wrong in my code.
If the model's content is set before the repeater is created it works, a model reset must be triggered to see the problem (this is what I use the qml timer for).
The symptom for the warning is that "this == sibling".
Complete project is attached.
#include <QtGui> #include <QtCore> #include <QtQuick> class MyModel : public QAbstractListModel { Q_OBJECT public: MyModel(QObject *parent = 0) : QAbstractListModel(parent) { QHash<int, QByteArray> roleNames; roleNames[Qt::UserRole + 1] = "text"; setRoleNames(roleNames); } int rowCount(const QModelIndex &) const { return m_data.size(); } int columnCount(const QModelIndex &) const { return 1; } Q_INVOKABLE void setStuff() { QStringList s; s << "One" << "two" << "three"; beginResetModel(); m_data = s; endResetModel(); } QVariant data(const QModelIndex &index, int) const { return m_data.at(index.row()); } private: QStringList m_data; }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQuickView viewer; MyModel m; viewer.rootContext()->setContextProperty("theModel", &m); viewer.setSource(QUrl("qrc:/qml/untitled3/main.qml")); viewer.show(); return app.exec(); } #include "main.moc"
import QtQuick 2.0 Rectangle { width: 360 height: 360 Column { anchors.fill: parent Repeater { id: repeater model: theModel delegate: Row { Text { text: "Yeah " + model.text } } } } Timer { // used to trigger model reset interval: 1000 onTriggered: theModel.setStuff() running: true repeat: true } }