How to draw a rectangle and adjust its shape by drag and drop in PyQt5
I'm trying to draw a rectangle on GUI created by PyQt5 by drag and drop. I managed to do that, but the rectangle is drawn when the mouse left key is released. What I want to do is like this link : When the mouse left button is pressed, start drawing the rectangle. While dragging, adjust the rectangle shape with the mouse movement. When the mouse left button is released, determine the rectangle shape. How can I implement this? Thanks in advance. Here's my code. # -*- coding: utf-8 -*- import sys from PyQt5 import QtWidgets, QtCore from PyQt5.QtGui import QPainter class MyWidget(QtWidgets