thank you so much i will try it Octal. i will read upon Qt::BackgroundRole too.
regards
Added after 1 17 minutes:
Hey i tried looking at the code but din't understand how to use it exactly. . This is what i am to doing after retrieving the data from the db to update the table and show a Red QLed when there is some data out of limit. But i wanted to highlight the cells of the crossed limits. i could't figureout how to use it.
void datadisplay::Updatetable()
{
model->clear();
// Data is appended to pressuredata every second from the db.
for(int i=0;i< pressuredata.count(); i++)
{
model->setItem(i, 0, item);
}
model->setHeaderData(0, Qt::Horizontal, tr("ID"));
model->setHeaderData(1, Qt::Horizontal, tr("Pressure"));
model->setHeaderData(2, Qt::Horizontal, tr("RAW"));
tableView->setModel(model);
tableView->setAlternatingRowColors(true);
for(int kt=0; kt<pressuredata.count(); kt++) //QVector<QString> pressuredata;
{
if((maxval < pressuredata.at(kt).toFloat())||(minval > pressuredata.at(kt).toFloat()))
{
qLed2_2->setColor(Qt::red);
label_9->setText("Pressure Limit Excceded");
setlimiflag =1;
// limtposi = kt;
break;
}
else
setlimiflag =0;
}
void datadisplay::Updatetable()
{
QStandardItemModel *model ;
model = new QStandardItemModel();
model->clear();
// Data is appended to pressuredata every second from the db.
for(int i=0;i< pressuredata.count(); i++)
{
QStandardItem *item = new QStandardItem(pressuredata.at(i));
model->setItem(i, 0, item);
}
model->setHeaderData(0, Qt::Horizontal, tr("ID"));
model->setHeaderData(1, Qt::Horizontal, tr("Pressure"));
model->setHeaderData(2, Qt::Horizontal, tr("RAW"));
tableView->setModel(model);
tableView->setAlternatingRowColors(true);
for(int kt=0; kt<pressuredata.count(); kt++) //QVector<QString> pressuredata;
{
if((maxval < pressuredata.at(kt).toFloat())||(minval > pressuredata.at(kt).toFloat()))
{
qLed2_2->setColor(Qt::red);
label_9->setText("Pressure Limit Excceded");
setlimiflag =1;
// limtposi = kt;
break;
}
else
setlimiflag =0;
}
To copy to clipboard, switch view to plain text mode
can you guide me to how to use the code you suggested .,.
regards
Bookmarks