QTableWidget* tableWidget = new QTableWidget(this);
tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section, QTableCornerButton::section {
padding: 1px;border: none;
border-bottom: 1px solid rgb(75, 120, 154);
border-right: 1px solid rgb(75, 120, 154);
border-bottom: 1px solid gray;
background-color:rgba(75, 120, 154,1);
color:rgb(126,206,244);}")
同样可以通过ui来设置styleSheet
通过styleSheet设置QComboBox
QComboBox* comboBox = new QComboBox();
comboBox->setStyleSheet("QComboBox{border:1px solid gray;} \
QComboBox QAbstractItemView::item{height:20px;}\
QComboBox::down-arrow{image:url(:/icon/arrowdown);}\
QComboBox::drop-down{border:0px;}");
comboBox->setView(new QListView());
QTableWidget* tableWidget = new QTableWidget(this);tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section, QTableCornerButton::section { padding: 1px;border: none; border-bottom: 1px solid rgb(75, 120, 154); border-right: 1px so
#include <QStyledItemDelegate>
#include "stdafx.h"
class NoFocusDelegate: public QStyledItemDelegate
Q_OBJECT
public:
大家都知道通过样式表可以设置表格的整体样式:
QTableWidget * table = new QTableWidget(this);
table->setStyleSheet(“QTableWidget{border-top:1px solid blue;
border-left:1px solid blue;
border-right:1px solid blue;
border-bottom:1px dashed blue;}”);
但如果想设置某个具体单元格的边框样式,这个方法就不适用了。
QHeaderView // QTableWidget 标题头整个区域
background:transparent; // 整个标题头区域背景色
}QHeaderView::section // 标题头 每个单独的标题区域
font-size:14px; // 每个标题的...
(1). QTableWidget创建及属性设置
tableWidget = new QTableWidget(this);
tableWidget->setRowCount(10);
tableWidget->setColumnCount(3);
//tableWidget->setFrameShape(QFrame::NoFrame);//设置边框
//tableWidget->s