Answer the question
In order to leave comments, you need to log in
Qt C++ QTableWidget how to set row color?
Hello, I am unloading a row from the database into a table:
// Обновить таблицу
void MainWindow::table_now()
{
// Очистить таблицу
ui->tableWidget->clearContents();
ui->tableWidget->setRowCount(0);
QString dbzap = "select name,reiting,dat,comment from `Default`";
// Вывод в таблицу
QSqlQuery query;
query.exec(dbzap);
while (query.next())
{
ui->tableWidget->insertRow(ui->tableWidget->rowCount());
for (int i=0; i<4; i++){
QTableWidgetItem * item = new QTableWidgetItem(query.value(i).toString());
ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,i,item);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question