Pregunta

I am new to these forums. In a QTableWidget I am trying to validate the changed value of the QTableWidgetItem. If the new value is present elsewhere in the table, I need to revert the value back to the previous value. I have thought of using a temporary list but wanted to know if it is possible to have a custom signal or similar which could return the changed value as well as the previous value of the qtablewidgetitem. Thanks :)

¿Fue útil?

Solución

I think you are looking for the reimplementation of this method:

void QAbstractItemDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const [virtual]

Sets the data for the item at the given index in the model to the contents of the given editor.

The base implementation does nothing. If you want custom editing you will need to reimplement this function.

This would allow you to emit a signal here where a cell changes, both with the previous and current values.

There does not seem to be a convenience signal off-hand in QTableWidget for this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top