我需要使用 qtablewidget 检查特定值是否位于特定列中。
就我而言,我需要检查第一列 ID 是否已存在,如果是,我需要包含行的编号来更新该行,否则我想添加该行。
QT有没有提供解决方案来检查列或shou
我假设您正在第一列中查找您的值(这就是为什么 item(int,int) 中的第二个参数是 0)并且表名称是我的 QTableWidget
int rows = myQTableWidget->rowCount();
bool found = false;
for(int i = 0; i < rows; ++i)
{
if(myQTableWidget->item(i, 0)->text() == "Something")
{
//we have found our value so we can update 'i' row
found = true;
break;
}
}
if(!found)
{
//we didn't find our value, so we can insert row
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)