<div dir="ltr">Barry, thanks for sharing your code.<div><br></div><div>I'll try to adopt it and see if it works with QML as well.</div><div><br></div><div>Daniel</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-17 10:45 GMT+01:00 Barry Scott <span dir="ltr"><<a href="mailto:barry@barrys-emacs.org" target="_blank">barry@barrys-emacs.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wednesday 16 March 2016 14:46:58 Daniel Krause wrote:<br>
> Hello,<br>
><br>
> I have a TableView in QML:<br>
><br>
> import QtQuick 2.5<br>
> import QtQuick.Controls 1.4<br>
><br>
> TableView {<br>
>     x: 0<br>
>     y: 0<br>
>     width: 400<br>
>     height: 400<br>
>     TableViewColumn{<br>
>         role: "test"<br>
>         title: "Test"<br>
>     }<br>
>     model: listModel<br>
> }<br>
><br>
> and a list defined in python, the application is started from python:<br>
><br>
> from PyQt5.QtCore import QUrl<br>
> import sys<br>
> from PyQt5.QtQuick import QQuickView<br>
> from PyQt5.QtGui import QGuiApplication<br>
><br>
> if __name__ == '__main__':<br>
>     app = QGuiApplication(sys.argv)<br>
><br>
>     view = QQuickView()<br>
>     root_context = view.rootContext()<br>
><br>
>     list_model = ['item1', 'item2']<br>
><br>
>     root_context.setContextProperty('listModel', list_model)<br>
>     view.setSource(QUrl.fromLocalFile('_test.qml'))<br>
>     view.setResizeMode(QQuickView.SizeRootObjectToView)<br>
>     view.show()<br>
><br>
>     sys.exit(app.exec_())<br>
><br>
> [image: Inline-Bild 1]<br>
><br>
> Now I want to add a new item to the list:<br>
> list_model = list_model.append('item3')<br>
><br>
> How do I propagate that change to the view in QML?<br>
<br>
</div></div>I have not use QML but I have a been working with QTableView a lot recently.<br>
<br>
I found that if I did not implement a QAbstractTableModel and update by<br>
calling the right methods the view will not update correctly. See<br>
beginInsertRows/beingRemoveRows and the dataChanged signal.<br>
<br>
You can see my code for the table model here:<br>
<br>
<a href="https://github.com/barry-scott/git-workbench/blob/master/Source/wb_git_table_model.py" rel="noreferrer" target="_blank">https://github.com/barry-scott/git-workbench/blob/master/Source/wb_git_table_model.py</a><br>
<br>
Barry<br>
<br>
_______________________________________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></blockquote></div><br></div>