baray98
25th June 2010, 05:37
I made a QPainter from a QPrinter and found that I can not setClipping to true. Is this the norms of things i can not find any in the docs that is mentioning this.
QPainter painter ( printer) ; // printer was passed and initialized
painter.setClipping(true);
qDebug() << painter.hasClipping() ; // this always give me false
i am suspecting why my delegate is not painting it within the boundary of my rect. I have used the above painter like this. I am trying to print data out from QTableView
for (int r = info.startRow; r <= info.endRow; ++r)
{
for (int c = info.startCol; c <= info.endCol; ++c)
{
QModelIndex idx = model()->index(r,c);
QStyleOptionViewItem option = viewOptions();
option.rect = visualRect(idx);
if (r % 2 == 0)
{
QBrush brush(QColor(220, 220, 220), Qt::SolidPattern);
painter.fillRect(option.rect, brush);
}
itemDelegate()->paint(&painter, option, idx);
}
}
the output text is in option.rect
4837
output when text is is out of bounds
4838
note: pic above is the print out
baray98
QPainter painter ( printer) ; // printer was passed and initialized
painter.setClipping(true);
qDebug() << painter.hasClipping() ; // this always give me false
i am suspecting why my delegate is not painting it within the boundary of my rect. I have used the above painter like this. I am trying to print data out from QTableView
for (int r = info.startRow; r <= info.endRow; ++r)
{
for (int c = info.startCol; c <= info.endCol; ++c)
{
QModelIndex idx = model()->index(r,c);
QStyleOptionViewItem option = viewOptions();
option.rect = visualRect(idx);
if (r % 2 == 0)
{
QBrush brush(QColor(220, 220, 220), Qt::SolidPattern);
painter.fillRect(option.rect, brush);
}
itemDelegate()->paint(&painter, option, idx);
}
}
the output text is in option.rect
4837
output when text is is out of bounds
4838
note: pic above is the print out
baray98