Hi,

in my QTableWidgetItems, I try to display a list of (3) strings vertically ordered and with a border.

For this border, I'd like to draw the rect in a loop and change its y-coordinate, so the same rect should be painted vertically shifted.

This is my code:
Qt Code:
  1. rectStringEvent.setY(rectCell.y() + 20); // position of the first string
  2. rectStringEvent.setHeight(15); // rect height, should not be changed but it does!
  3.  
  4. for(int i = 0; i < 3; i++)
  5. {
  6. pPainter->drawText(rectStringEvent, listEvents.at(i));
  7. pPainter->drawRect(rectStringEvent);
  8. rectStringEvent.setY(rectStringEvent.y() + 15); // <--- this line is the problem: it also changes the rects height! But why?
  9. }
To copy to clipboard, switch view to plain text mode 
I figured out that the rect's height is decreased by the number I increase the y-coordinate. I don't understand this behaviour. Why can't I just change the y-coordinate and the rect moves and still has it's prior height?

Thank you in anticipation.
Binary