1. 程式人生 > >Qt中設定QTableWidget的表頭高度

Qt中設定QTableWidget的表頭高度

關鍵就是

ui->tableWidget->horizontalHeader()->setMinimumHeight(30);
ui->tableWidget->setHorizontalHeaderLabels(columnNames);
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget->verticalHeader()->setVisible(false);
ui->tableWidget->verticalHeader()->setDefaultSectionSize(30);
ui->tableWidget->horizontalHeader()->setMinimumHeight(30);
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);