Solved model populated signal
-
The fact the is editable or not is meaningless, if any change in your model should trigger a repaint in the view you should emit that signal
-
@VRonin
still no luck :( -
Can you post your model implementation?
-
@VRonin
sorry it's python. nothing specific to it, though.class TableModel(QAbstractTableModel): headers = [/* items */] def __init__(self, parent=None): super(TableModel, self).__init__(parent) self.__data = [] def rowCount(self, parent=QModelIndex()): del parent return len(self.__data) def columnCount(self, parent=QModelIndex()): del parent return len(self.headers) def data(self, index, role=Qt.DisplayRole): if not index.isValid() or \ not (0 <= index.row() < self.rowCount()) or \ not (0 <= index.column() < self.columnCount()): return QVariant() if role == Qt.DisplayRole: return self.__data[index.row()][index.column()] if role == Qt.UserRole: return self.__data[index.row()][0] return QVariant() def headerData(self, section, orientation, role): if role != Qt.DisplayRole: return QVariant() if orientation == Qt.Horizontal: return self.headers[section] return section + 1 def set_data(self, data): self.beginResetModel() del self.__data[:] # populate self.__data self.endResetModel() self.dataChanged.emit(self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1))
-
You are using reset model so you can connect to
QAbstractItemModel::modelReset
-
@VRonin
that's what i tried firstactually, the first time model is populated, the slot isn't invoked, but when it's populated 2nd time, the slot is invoked (with both signals)
-
@user4592357 said in model populated signal:
the slot isn't invoked
void QAbstractItemModel::endResetModel() { Q_D(QAbstractItemModel); d->invalidatePersistentIndexes(); QMetaObject::invokeMethod(this, "resetInternalData"); emit modelReset(QPrivateSignal()); }
-
@VRonin
yeahanother weird thing: the 2nd time it's invoked, 3rd time it's invoked twice, 4th time - thrice, etc...
-
Where are you connecting the signal? looks like you are connecting every time it's invoked
-
@VRonin
my bad, right...how didn't i realize? thanks