QTableWidget 设置表头颜色

QTableWidget 设置表头颜色

方法1:

setStyleSheet( "QHeaderView::section {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #00007f, stop: 0.5 #00007f,stop: 0.6 #00007f, stop:1 #00007f);color: white;}");

方法2:

setStyleSheet(
		"QTableWidget{ color:black; \
					     background-color:rgb(224,224,224);\
						 selection-color:rgb(0, 0, 0); \
						 selection-background-color:rgb(	100,149,237);\
					     border:0px;\
						 font: 8pt 'Microsoft YaHei' ;}"
		"QHeaderView::section:horizontal{ 	/*设置标题(水平的)*/\
						border: 1px solid rgb(255, 255, 255); 	/*白色间隔*/\
						border - bottom: 0px;/*下边框不需要颜色*/\
						color: rgb(2, 65, 132);\
						background: transparent;\
						padding - left: 2px;\
						min - width:60px;}");

以下方法尝试无效果

ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:skyblue;}");

你可能感兴趣的:(qt,c++)