QT开发中文网

no member named setItem in QTableView

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助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://qt.0voice.com/?id=9097

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?