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
QPainter painter ( printer) ; // printer was passed and initialized
painter.setClipping(true);
qDebug() << painter.hasClipping() ; // this always give me false
To copy to clipboard, switch view to plain text mode
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)
{
option.rect = visualRect(idx);
if (r % 2 == 0)
{
painter.fillRect(option.rect, brush);
}
itemDelegate()->paint(&painter, option, idx);
}
}
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);
}
}
To copy to clipboard, switch view to plain text mode
the output text is in option.rect
sampleGood..JPG
output when text is is out of bounds
sampleBad..JPG
note: pic above is the print out
baray98
Bookmarks