model populated signal
-
@VRonin
is that the correct one to use?it didn't activate the slot
@user4592357 said in model populated signal:
it didn't activate the slot
That means you didn't implement the model correctly, see http://doc.qt.io/qt-5/qabstractitemmodel.html#subclassing it's not easy :)
-
@user4592357 said in model populated signal:
it didn't activate the slot
That means you didn't implement the model correctly, see http://doc.qt.io/qt-5/qabstractitemmodel.html#subclassing it's not easy :)
@VRonin
do you mean emittingdataChanged()? my model isn't editable so i don't need it -
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 :( -
@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)) -
@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)
-
@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()); } -
@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...
-
@VRonin
my bad, right...how didn't i realize? thanks