by looking into setWindow and setViewPort,

I understood that by setWindow i can tell the painter the rect i want it to draw in it.
so i did this :

Qt Code:
  1. QRect widgetRect = this->rect();
  2. QRect windowRect;
  3.  
  4. windowRect.setHeight(widgetRect.height()-50);
  5. windowRect.setWidth(widgetRect.width()-50);
  6. windowRect.setX(widgetRect.x()-50);
  7. windowRect.setY(widgetRect.y()-50);
  8.  
  9. painter.setWindow(windowRect);
  10. painter.drawRect(myRect);
To copy to clipboard, switch view to plain text mode 


expecting that when i draw using the painter it will draw inside this windowRect.

but it does not, it will draw out of the border in the invisable area for the user.

I dont know what exactlly i should set it.