The code does not help much. We need to see how you make your drawing. But before: Your widget stays a square or your drawing?

to determine you can use:
Qt Code:
  1. void WykresSlupkowy::paintEvent(QPaintEvent *event)
  2. {
  3. paintMyWidget();
  4. QWidget::paintEvent(event);
  5. QPainter p(this);
  6. p.setPen(QPen(Qt::red, 1));
  7. p.drawRect(rect().adjusted(0, 0, -1, -1));
  8. }
To copy to clipboard, switch view to plain text mode 
So is the red border always a square?