:db:sStrong
25th July 2006, 10:01
hello ppl,
I have reimplemented paintCell, i want to give the cells of my table a color.. i have 10 cells and i want that the 5 cells should get a color.. like the first cell white and the second yellow and the third white, fourth yellow .....
this is my code i am only able to color the 3 cells ...
void myTable::paintCell(QPainter *p, int row, int col, const QRect &cr, bool selected, const QColorGroup &cg)
{
int numRows = this->numRows();
int countRows = numRows;
for(int i = 0; i < numRows ; i++)
if (row == numRows-- || row == numRows+i || row == numRows-i || row == numRows+i
|| row ==numRows-i)
{
QColorGroup colorGroup(cg);
colorGroup.setColor(QColorGroup::Base, QColor("#ffffbb"));
QTable::paintCell(p, row, col, cr, selected, colorGroup);
}
else
{
QTable::paintCell(p, row, col, cr, selected, cg);
}
}
can anyone take a look at the code?
thanx in advance
I have reimplemented paintCell, i want to give the cells of my table a color.. i have 10 cells and i want that the 5 cells should get a color.. like the first cell white and the second yellow and the third white, fourth yellow .....
this is my code i am only able to color the 3 cells ...
void myTable::paintCell(QPainter *p, int row, int col, const QRect &cr, bool selected, const QColorGroup &cg)
{
int numRows = this->numRows();
int countRows = numRows;
for(int i = 0; i < numRows ; i++)
if (row == numRows-- || row == numRows+i || row == numRows-i || row == numRows+i
|| row ==numRows-i)
{
QColorGroup colorGroup(cg);
colorGroup.setColor(QColorGroup::Base, QColor("#ffffbb"));
QTable::paintCell(p, row, col, cr, selected, colorGroup);
}
else
{
QTable::paintCell(p, row, col, cr, selected, cg);
}
}
can anyone take a look at the code?
thanx in advance