Qt表格

1、设置QTableWidget或QTableView的首行首列背景色
  ->horizontalHeader()->setStyleSheet("QHeadView::section{background-color: rgb(231,231,231);}");
  ->verticalHeader()->setStyleSheet("QHeadView::section{background-color: rgb(231,231,231);}");
  ->setStyleSheet("background-color: rgb(231,231,231);");//首行首列可能会失效

2、自适应列宽和自动等宽
  ->horizontalHeader()->setSectionResizeMode( );

原文地址:https://www.cnblogs.com/wangbin-heng/p/9657565.html