posts - 10,comments - 1,views - 23577

//不可编辑
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);

ui.tableWidget->setFocusPolicy(Qt::NoFocus); //去除选中虚线框

//windows10情况下添加表头下边框

if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS10) {
setStyleSheet(
"QHeaderView::section{"
"border-top:0px solid #D8D8D8;"
"border-left:0px solid #D8D8D8;"
"border-right:1px solid #D8D8D8;"
"border-bottom: 1px solid #D8D8D8;"
"background-color:white;"
"padding:4px;"
"}"
"QTableCornerButton::section{"
"border-top:0px solid #D8D8D8;"
"border-left:0px solid #D8D8D8;"
"border-right:1px solid #D8D8D8;"
"border-bottom: 1px solid #D8D8D8;"
"background-color:white;"
"}");
}

posted on   青春凹陷  阅读(379)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示