wysota, thanks for helping me with this.

Since I inherited the QTableWidget, release deadlines require me to continue its use, although from everything I've read I really need a QTableView. Since I'm already using a delegate to handle other table cell validation it would seem to make sense to explore the setModelData() route.

Does something like this appear appropriate (provided I don't mess up the validation code)?

Qt Code:
  1. void DMXTableCellDelegate::setModelData( QWidget* editor, QAbstractItemModel* model,
  2. const QModelIndex& index ) const
  3. {
  4. if ( index.column() == COL_Name )
  5. {
  6. QLineEdit* lineEdit = qobject_cast<QLineEdit*>( editor );
  7.  
  8. if ( lineEdit != NULL && !lineEdit->text().isEmpty() )
  9. {
  10. QString sValidStr = lineEdit->text();
  11.  
  12. // validate will return true if the string was modified
  13. if ( validate( sValidStr ) == true )
  14. {
  15. // update the model with the modified string
  16. model->setData( index, sValidStr );
  17. return;
  18. }
  19. }
  20. }
  21.  
  22. // validate did NOT modify the string
  23. QItemDelegate::setModelData( editor, model, index );
  24. }
To copy to clipboard, switch view to plain text mode