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:
{
if ( Qt::DisplayRole == role )
{
v = "whatever";
if ( indexIsAHeaderRow( index ) )
emit setColumnSpanForHeaderRow( index.row(), index.column() );
}
return v;
}
QVariant MyCustomModel::data( const QModelIndex & index, int role )
{
QVariant v;
if ( Qt::DisplayRole == role )
{
v = "whatever";
if ( indexIsAHeaderRow( index ) )
emit setColumnSpanForHeaderRow( index.row(), index.column() );
}
return v;
}
To copy to clipboard, switch view to plain text mode
Bookmarks