I am have been programming a tableview but I have a nagging problem for which I haven't been able to find any relevant posts.
I have the following code:
AttributeMapModel* model = new AttributeMapModel( canonical_fields, mapped_fields, user_fields ) ;
AttributeDelegate* item_delegate = new AttributeDelegate;
ui.AttributeMappingTable->setModel( model );
model->setHeaderData( 0, Qt::Horizontal, "User Fields", Qt::DisplayRole );
model->setHeaderData( 1, Qt::Horizontal, "Rules", Qt::DisplayRole );
ui.AttributeMappingTable->setItemDelegate( item_delegate );
ui.
AttributeMappingTable->horizontalHeader
()->setResizeMode
(QHeaderView::Stretch);
ui.
AttributeMappingTable->verticalHeader
()->setResizeMode
(QHeaderView::Stretch);
ui.AttributeMappingTable->verticalHeader()->setStretchLastSection(true);
AttributeMapModel* model = new AttributeMapModel( canonical_fields, mapped_fields, user_fields ) ;
AttributeDelegate* item_delegate = new AttributeDelegate;
ui.AttributeMappingTable->setModel( model );
model->setHeaderData( 0, Qt::Horizontal, "User Fields", Qt::DisplayRole );
model->setHeaderData( 1, Qt::Horizontal, "Rules", Qt::DisplayRole );
ui.AttributeMappingTable->setItemDelegate( item_delegate );
ui.AttributeMappingTable->setEditTriggers( QAbstractItemView::CurrentChanged |
QAbstractItemView::AnyKeyPressed );
ui.AttributeMappingTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
ui.AttributeMappingTable->verticalHeader()->setResizeMode(QHeaderView::Stretch);
ui.AttributeMappingTable->verticalHeader()->setStretchLastSection(true);
To copy to clipboard, switch view to plain text mode
The horizontal header resizes as specified but the vertical header leaves space at the bottom after the last row which, if the mouse cursor enters it, causes an assert in QHeaderView::setSectionSize(). Q_ASSERT(visual != -1); This is a nuisance but the sizing is aethestically unpleasing itself. Am I missing something?
Note: I am developing under Qt 4.0.1 I hope this doesn't require an upgrade.
Bookmarks