表格隐藏顶部栏和左侧框,设置单元格部件
作者:互联网
#define M_FACE_WIDTH 40
#define M_ROW_NUM 3
#define M_COL_NUM 4
class FacesTab :
public QTableWidget
{
Q_OBJECT
public:
FacesTab();
~FacesTab();
};
FacesTab::FacesTab()
{
setRowCount(M_ROW_NUM);
setColumnCount(M_COL_NUM);
QHeaderView* headerView = verticalHeader();
headerView->setHidden(true);
headerView = horizontalHeader();
headerView->setHidden(true);
for (int i = 0; i < M_ROW_NUM; i++) {
setRowHeight(i, M_FACE_WIDTH);
}
for (int j = 0; j < M_COL_NUM; j++) {
setColumnWidth(j, M_FACE_WIDTH);
}
QPushButton * tmpButton = new QPushButton("tmp");
tmpButton->setFixedSize(M_FACE_WIDTH,M_FACE_WIDTH);
setCellWidget(0, 0, tmpButton);
setFixedSize(M_FACE_WIDTH*M_COL_NUM + 2,M_FACE_WIDTH*M_ROW_NUM + 2 );
}
标签:headerView,表格,单元格,FACE,WIDTH,NUM,左侧,COL,FacesTab 来源: https://blog.csdn.net/shensheng100221/article/details/104746222