Hello!
Many thanks for this project. :)
My question: i try to colorize the separate items of the chart, for example:
itemModel->setData(itemModel->index(i, j), Qt::red, Qt::BackgroundRole);
or
itemModel->setData(itemModel->index(i, j), Qt::blue, Qt::ForegroundRole);
and the objects are not colorized. what is wrong?
thank you!
all right, i solved it.
replaced in BarChartPlotter::drawContent
// QPen pen(qvariant_cast<QColor>(m_model->headerData(j, Qt::Vertical, Qt::ForegroundRole)));
// QBrush brush(qvariant_cast<QBrush>(m_model->headerData(j, Qt::Vertical, Qt::BackgroundRole)));
QPen pen(qvariant_cast<QColor>(m_model->data(m_model->index(j,i), Qt::ForegroundRole)));
QBrush brush(qvariant_cast<QBrush>(m_model->data(m_model->index(j,i), Qt::BackgroundRole)));
this solution i need for colorized displaing of percent information, f. ex: about 35% is red and so on
Ratings & Comments
2 Comments
Hello! Many thanks for this project. :) My question: i try to colorize the separate items of the chart, for example: itemModel->setData(itemModel->index(i, j), Qt::red, Qt::BackgroundRole); or itemModel->setData(itemModel->index(i, j), Qt::blue, Qt::ForegroundRole); and the objects are not colorized. what is wrong? thank you!
all right, i solved it. replaced in BarChartPlotter::drawContent // QPen pen(qvariant_cast<QColor>(m_model->headerData(j, Qt::Vertical, Qt::ForegroundRole))); // QBrush brush(qvariant_cast<QBrush>(m_model->headerData(j, Qt::Vertical, Qt::BackgroundRole))); QPen pen(qvariant_cast<QColor>(m_model->data(m_model->index(j,i), Qt::ForegroundRole))); QBrush brush(qvariant_cast<QBrush>(m_model->data(m_model->index(j,i), Qt::BackgroundRole))); this solution i need for colorized displaing of percent information, f. ex: about 35% is red and so on