表格快速搜索

{
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(search(QString)));
}

void MainWindow::search(QString s)
{
    for (int r=0; rtableWidget->rowCount(); r++) {
        if (ui->tableWidget->item(r,0)->text().contains(s))
            ui->tableWidget->setRowHidden(r, false);
        else
            ui->tableWidget->setRowHidden(r, true);
    }
}

你可能感兴趣的:(Qt,qt)