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.

Qt Code:
  1. QPainter painter ( printer) ; // printer was passed and initialized
  2. painter.setClipping(true);
  3.  
  4. 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
Qt Code:
  1. for (int r = info.startRow; r <= info.endRow; ++r)
  2. {
  3. for (int c = info.startCol; c <= info.endCol; ++c)
  4. {
  5. QModelIndex idx = model()->index(r,c);
  6. QStyleOptionViewItem option = viewOptions();
  7. option.rect = visualRect(idx);
  8. if (r % 2 == 0)
  9. {
  10. QBrush brush(QColor(220, 220, 220), Qt::SolidPattern);
  11. painter.fillRect(option.rect, brush);
  12. }
  13.  
  14. itemDelegate()->paint(&painter, option, idx);
  15. }
  16. }
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