modelInstruction->setData(modelInstruction->index(0, 0), Qt::blue, Qt::BackgroundRole);
Вот кусок кода:
QSqlQueryModel *modelInstruction = new QSqlQueryModel;
tableViewInfo->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
str = "SELECT instruction.inf, doctors.surname, instruction.time FROM instruction, doctors WHERE instruction.iduser = %1 AND instruction.iddoctor = doctors.id ORDER BY instruction.id DESC LIMIT 30;";
str = str.arg(id);
modelInstruction->setQuery(str);
modelInstruction->setHeaderData(0, Qt::Horizontal, tr("Doctor's \ninstruction"), Qt::DisplayRole);
modelInstruction->setHeaderData(1, Qt::Horizontal, tr("Doctor's\n surname"), Qt::DisplayRole);
modelInstruction->setHeaderData(2, Qt::Horizontal, tr("Departure\ntime"), Qt::DisplayRole);
modelInstruction->setData(modelInstruction->index(0, 0), Qt::blue, Qt::BackgroundRole);
tableViewInfo->setModel(modelInstruction);