开发者

QT how to select and change all coulmns of QStandardItemModel

开发者 https://www.devze.com 2023-01-01 09:35 出处:网络
im trying to programmatic select and change the background color of all the columns 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))开发者_如何学JAVA);


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..

0

精彩评论

暂无评论...
验证码 换一张
取 消