小凡慢慢学
慢慢学,更有趣

效果图:

 

 1     ui->tableWidget->setColumnCount(3);
 2     ui->tableWidget->verticalHeader()->hide();
 3     ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
 4     ui->tableWidget->horizontalHeader()->setStretchLastSection(true);  // 最后一列伸缩铺满
 5     ui->tableWidget->setHorizontalHeaderLabels(QStringList()
 6                                                       << tr("Device IP") << tr("EP Address")  << tr("Type"));
 7     ui->tableWidget->setColumnWidth(0, 200);
 8     ui->tableWidget->setColumnWidth(1, 400);
 9     ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
10     ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
11     ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);

 

posted on 2015-01-07 15:10  小凡慢慢学  阅读(6101)  评论(0编辑  收藏  举报