QTableWidget表格样式调整
作者:互联网
//不可编辑
ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
//点击一次选中一行
ui.tableWidget->setSelectionBehavior(QTableWidget::SelectRows);
//只能选中单行
ui.tableWidget->setSelectionMode(QTableWidget::SingleSelection);
//取消默认行号
ui.tableWidget->verticalHeader()->setHidden(true);
//横向填充表格
//ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
//横向填充表格情况下调整某列为最小值
//ui.tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
//ui.tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
标签:QHeaderView,表格,样式,QTableWidget,setSectionResizeMode,tableWidget,ui,horizontalHea 来源: https://www.cnblogs.com/aoxian/p/15912682.html