user63898
user63898

Reputation: 30915

QT how to select and change all coulmns of QStandardItemModel

im trying to programmatic select and change the background color of all the columns of QStandardItemModel
i have this that paint me only the first column out of 5 that the row contains

// getting the rows
QStandardItem* standardItem = m_model->item(i);
//set the color i like all the row to be painted
standardItem->setBackground(QBrush(QColor(255,0,0)));

Upvotes: 0

Views: 1790

Answers (1)

liaK
liaK

Reputation: 11648

Try this..

for(int i = 0; i<rowCount; ++i)
{
   for(int j = 0; j<columnCount; ++j)
       {
            m_model->item(i,j)->setBackground(QBrush(QColor(255,0,0)));
       }
}

This isn't tested.. check it out..

Upvotes: 1

Related Questions