且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

QableWidget:如何在特定列中查找值

更新时间:2022-11-19 11:37:57

我假设您在第一列中查找值(因此Item(int,int)中的第二个参数为0),表名为MyQTableWidget

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
}