ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置不可编辑
ui->tableWidget->verticalHeader()->setVisible(false); //设置垂直头不可见
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); //设置选择行为时每次选择一行
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection); //设置不可多选 (Ctrl、Shift和Ctrl+A)
ui->tableWidget->setFrameShape(QFrame::NoFrame); //设置无边框
ui->tableWidget->setShowGrid(false); //不显示格子线
ui->tableWidget->horizontalHeader()->setStretchLastSection(true); //设置充满表宽度
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
//ui->tableWidget->horizontalHeader()->setDefaultSectionSize(140); //默认宽度
ui->tableWidget->horizontalHeader()->setMaximumSectionSize(140);
ui->tableWidget->setItemDelegate(new NoFocusDelegate()); //虚线边框去除
ui->tableWidget->horizontalHeader()->setHighlightSections(false); //点击表时不对表头行光亮(获取焦点)
//设置表头背景色
ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:skyblue;}"); ui->tableWidget->setStyleSheet("selection-background-color:lightblue;"); //设置选中背景色
//设置表格隔行换色
ui->tableWidget->setAlternatingRowColors(true);
ui->tableWidget->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" "alternate-background-color: rgb(50, 110, 255);}"); //某一列不能编辑
item = new QTableWidgetItem(str);
item->setFlags(item->flags() & (~Qt::ItemIsEditable));

QTableWidget表格属性的更多相关文章

  1. PyQt(Python+Qt)学习随笔:QTableWidget表格部件中行高和列宽的计算方式

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 QTableWidget表格部件中行高和列宽的计算在Qt提供的资料中内容介绍比较泛,细节说得不清楚, ...

  2. html表格属性

    一.在表格中插入文字及图片 1.把图片及文字分开到不同的[tr]标签表格内. <html> <body> <table border="1" widt ...

  3. PyQt(Python+Qt)学习随笔:QTableWidget的属性

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 1.概述 除了从父类继承的属性外,在Designer中QTableWidget只有两个属性,就是行数 ...

  4. QTableWidget表格合并若干问题及解决方法

    Qt提供 QTableWidget作为表格的类以实现表格的基本功能,表格中所装载的每一个单元格由类QTableWidgetItem提供.这是基于表格实现 Qt提供的一个基础类,若想实现定制表格和单元格 ...

  5. 表格属性和BFC(block framing content)

    th和tr都是表示列但是 th有一个居中加粗的效果. 表单是由 : 1表单域:<form name=" " method="get/post"  acti ...

  6. HTML表格属性及简单实例

    这里主要总结记录下表格的一些属性和简单的样式,方便以后不时之需. 1.<table> 用来定义HTML的表格,具有本地属性 border 表示边框,border属性的值必须为1或空字符串( ...

  7. bootstrap table表格属性、列属性、事件、方法

    留存一份,原文地址http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/ 表格参数 表格的参数定义在 jQuery.fn.bootst ...

  8. 批量修改WORD表格属性

    有时候需要对word中很多表格的属性进行修改,而word无法批量修改属性,所有这里记录一个宏 Sub TableFormatter() Dim oTbl As Table, i As Integer ...

  9. jquery easyui DataGrid 数据表格 属性

    用法 1.  <table id="tt"></table> 1.  $('#tt').datagrid({ 2.      url:'datagrid_d ...

随机推荐

  1. Mysql基础知识--概述和索引

    一.Mysql概述 MySQL原来隶属于MySQL公司,总部位于瑞典 2008.1.16MySQL被SUN公司收购 2009年SUN公司被Oracle公司收购 常见的软件版本 GA(general A ...

  2. 【Spring 整合篇】整合SpringMVC+Mybatis(一)

    首先,创建Maven Project,packaging为war,修改pom.xml. <properties> <!-- JDK版本 --> <java.version ...

  3. arduino雨滴传感器

    https://blog.csdn.net/yichu5074/article/details/81074055 功能介绍:接上5V电源,电源指示灯亮,感应板上没有水滴时,DO输出为高电平,开关指示灯 ...

  4. 【转】hibernate对象三种状态

    hibernate里对象有三种状态: 1,Transient 瞬时 :对象刚new出来,还没设id,设了其他值. 2,Persistent 持久:调用了save().saveOrUpdate(),就变 ...

  5. [LeetCode] 139. Word Break 拆分词句

    Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine ...

  6. 关于Windows自动化卸载软件的思路

    思路 关于控制面板“卸载”关联到的exe是这样的: 注册表:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall ...

  7. SpringBoot集成Spring Security(1)——入门程序

    因为项目需要,第一次接触 Spring Security,早就听闻 Spring Security 功能强大但上手困难,学习了几天出入门道,特整理这篇文章希望能让后来者少踩一点坑(本文附带实例程序,请 ...

  8. 第17课 lambda表达式

    一. lambda表达式 (一)语法定义:[capture](paramters) mutable ->returnType{statement} 1.[capture]:捕获列表 (1)lam ...

  9. Spring69道面试题

    Spring 概述 1. 什么是spring? Spring 是个java企业级应用的开源开发框架.Spring主要用来开发Java应用,但是有些扩展是针对构建J2EE平台的web应用.Spring  ...

  10. 小记:iterator && auto

    小记:iterator && auto iterator 众所周知,我们有一种强大的东西,它叫做STL,比如queue.vector.set.map.multimap .deque等. ...