[solved]QAbstractListModel - update data in table view [linux]
-
The signal will just tell you that the file has changed, it will not reload the content for you. You'll have to parse the file again and update stockdata with what you just read from it
-
One more thing.
file_check = QtCore.QFileSystemWatcher(['/home/user/Desktop/plik.txt'])
file_check only checks if file was changed if was:file_check.fileChanged.connect(resetItems)
it sends signal to 'resetItems' and 'resetItems' should reload data, true?
and I have to find a way how accept the string parameter emitted by fileChanged.. -
Is it better ? but I have got error like that:
AttributeError: 'StockListModel' object has no attribute 'beginResetModel'@def init(self, stockdata = [], parent = None):
QtCore.QAbstractListModel.init(self, parent)
self.stockdata = stockdata
self.file_check = QtCore.QFileSystemWatcher(['/home/user/Desktop/file.txt'])
self.file_check.fileChanged.connect(self.resetItems)def getItems(self): return stockdata @QtCore.pyqtSlot(str) def resetItems(self, path): self.beginResetModel() ....
@
-
You have to the data reloading yourself. Like in your main function.
As for beginResetModel I don't know why it's saying that
-
Yes, that's what I mean. On you program startup you are reading that file and put it's content in the stockdata variable. When the QFileSystemWatcher triggers, you must do that parsing again.
-
You're welcome !
Since you have it working now, please update the thread title prepending [solved] so that other forum users may know a solution has been found :)