Quote Originally Posted by d_stranz View Post
If you're using a custom model, then you want QTableView, not QTableWidget, no?

Could you not reimplement QAbstractItemModel::span() to do this? (Duh, I should RTFM - "Note: Currently, span is not used." That's exactly what you need).

What you're asking for sort of breaks the model / view separation. I think you might be able to accomplish what you want by implementing a signal in a custom model that is emitted whenever the Qt::DisplayRole is requested for one of these header row indexes in the QAbstractTableModel::data() method. The widget that contains your QTableView could listen for this signal and set the column span appropriately.

Something like:

Qt Code:
  1. QVariant MyCustomModel::data( const QModelIndex & index, int role )
  2. {
  3. if ( Qt::DisplayRole == role )
  4. {
  5. v = "whatever";
  6. if ( indexIsAHeaderRow( index ) )
  7. emit setColumnSpanForHeaderRow( index.row(), index.column() );
  8. }
  9. return v;
  10. }
To copy to clipboard, switch view to plain text mode 

Thanks. I will give it a whirl. Yes, I meant View. Shouldn't type posts first thing Sunday morning I guess.