When moving the scroll, the circles are drawn not centered.
import sys from PyQt5.QtWidgets import QVBoxLayout, QWidget, QApplication, QLabel, QHBoxLayout, QScrollArea from PyQt5.QtGui import QPainter, QColor, QMouseEvent, QImage, QPixmap, QPalette from PyQt5.QtCore import Qt, QPoint class Example(QWidget): def __init__(self): super().__init__() self.flag = False self.initUI() def initUI(self): self.resize(500, 500) self.image = QImage(self.width(), self.height(), QImage.Format_ARGB32) self.image.fill(QColor(255, 255, 255)) self.hbox = QHBoxLayout() self.label = QLabel() self.label.setAlignment(Qt.AlignLeft) scroll = QScrollArea() self.valueWidth = scroll.verticalScrollBar().value() scroll.setBackgroundRole(QPalette.Dark) self.label.setGeometry(10, 10, 500, 500) self.label.setPixmap(QPixmap.fromImage(self.image)) scroll.setWidget(self.label) self.hbox.addWidget(scroll) self.setLayout(self.hbox) self.show() def mousePressEvent(self, e): if e.button() != Qt.LeftButton: self.flag = False if e.button() == Qt.LeftButton: self.flag = True self.paint = QPainter(self.image) self.ellips(e) def paintEvent(self, e): paint = QPainter(self) self.label.setPixmap(QPixmap.fromImage(self.image)) def mouseMoveEvent(self, e): if self.flag: print(e.pos()) self.ellips(e) def ellips(self,e): self.paint.setBrush(QColor('yellow')) self.paint.drawEllipse(e.pos() - QPoint(10, 10), 20, 20) self.update() app = QApplication(sys.argv) w = Example() sys.exit(app.exec_()) 