QTableWidget column宽度的设置

来源:互联网 发布:sql 2008 r2 64位下载 编辑:程序博客网 时间:2024/06/11 10:05

 
qcdataTable->verticalHeader()->setHidden(true);
qcdataTable->setColumnWidth(0, 50);
qcdataTable->setColumnWidth(1, 50);

qcdataTable->horizontalHeader()->setResizeMode(0,QHeaderView::Fixed);
qcdataTable->horizontalHeader()->setStretchLastSection(true);


如果改成

qcdataTable->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
qcdataTable->horizontalHeader()->setStretchLastSection(true);

则除最后一列随边框变化外,其余宽度不能改变。


QHeaderView::Interactive  0   The user can resize the section. The section can also be resized programmatically usingresizeSection()

QHeaderView::Fixed          2    The user cannot resize the section. The section can only be resized programmatically using resizeSection()

QHeaderView::Stretch        1    will automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically

QHeaderView::ResizeToContents 3    will automatically resize the section to its optimal size based on the contents of the entire column or row. The size cannot be changed by the user or programmatically

原创粉丝点击