Hello,
I am using following code to assign data and color to contents of QTableView:
for(y=0; y<7; y++)
{
if(y==6)
{
if(nepopolno)
item->setData("krizec",Qt::DisplayRole);
else
item->setData("kljukica",Qt::DisplayRole);
}
else
item->setData(ukaz.value(y).toString(),Qt::DisplayRole);
item->setData(ukaz.value(6).toString(),Qt::UserRole);
item->setBackground(Qt::red);
model.setItem(vrsta,y,item);
}
for(y=0; y<7; y++)
{
QStandardItem* item=new QStandardItem();
if(y==6)
{
if(nepopolno)
item->setData("krizec",Qt::DisplayRole);
else
item->setData("kljukica",Qt::DisplayRole);
}
else
item->setData(ukaz.value(y).toString(),Qt::DisplayRole);
item->setData(ukaz.value(6).toString(),Qt::UserRole);
item->setBackground(Qt::red);
model.setItem(vrsta,y,item);
}
To copy to clipboard, switch view to plain text mode
Variable y represents column as you can see. Problem I face is that only first column is colored. If I debug with debugger, then I see that item->setBackground() method is certainly called for every QStandardItem of model that is assigned to QTableView.
Any clues how to write this code correctly? Or is there some other issue with Qt?
Bookmarks