Apologies for the confusion. If you are using a QTableView instead of a QTableWidget, you can utilize a model (e.g., QStandardItemModel) to set data at specific row and column positions.
Here’s an example:
QString data = "数据";
int row = 1; // Second row
int column = 0; // First column
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(ui->m_tableClientsIP->model());
if (model) {
QModelIndex index = model->index(row, column);
model->setData(index, data);
}
Make sure that m_tableClientsIP is properly initialized with a model (e.g., QStandardItemModel). This code sets the data at the specified position in the table view using the setData() function of the model.
内容由零声教学AI助手提供,问题来源于学员提问