代码
void MainWindow::on_actAppend_triggered()
{
QList<QStandardItem*>itemList;
QStandardItem * item;
int i;
for(i = 0; i < FixedColoumCount -1; i++){
item = new QStandardItem("0");
itemList << item;
}
QString str = theModel->headerData(theModel->columnCount() -1,
Qt::Horizontal, Qt::DisplayRole).toString();
item = new QStandardItem(str);
item->setCheckState(Qt::Checked);
itemList << item;
theModel->appendRow(itemList);
theSelection->clearSelection();
QModelIndex index = theModel->index(theModel->rowCount() -1 , 0);
theSelection->setCurrentIndex(index, QItemSelectionModel::Select);
}
图片