QTableWidget: 1 //设置表头 2 QStringList heardList;//表头 3 heardList << QString::frLocal8Bit("接收")<<QString::frLocal8Bit("发送"); 4 ui.tableWidget>setColumnCount(heardListount()); 5 ui.tableWidget>setHorizontalHeaderLabels(heardList);
QTableView:
1 QStringList heardList;//表头 2 heardList << QString::frLocal8Bit("接收")<<QString::frLocal8Bit("发送"); 3 QHeaderView *hearview = new QHeaderView(Qt::Horizontal); 4 QStandardItemModel* model = new QStandardItemModel; 5 model>setHorizontalHeaderLabels(heardList); 6 hearview>setModel(model); 7 hearview>setSectionResizeMode(QHeaderView::Stretch); //先自适应宽度 8 hearview>setSectionResizeMode(0, QHeaderView::ResizeToContents); //然后设置要根据内容使用宽度的列 9 ui.tableView>setHorizontalHeader(hearview);上一篇:Qt 检查int某一位数据是否为1
下一篇:C++ std::floor和std:ceil简述
Qt









