Skip to content

Instantly share code, notes, and snippets.

@eyllanesc
Created October 15, 2018 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyllanesc/59c676c12467a672f456cab559642b87 to your computer and use it in GitHub Desktop.
Save eyllanesc/59c676c12467a672f456cab559642b87 to your computer and use it in GitHub Desktop.
from PyQt5 import QtCore, QtGui, QtWidgets
class PixmapItem(QtWidgets.QGraphicsPixmapItem):
def __init__(self, parent=None):
super().__init__(parent)
self.setAcceptDrops(True)
self.setPixmap(QtGui.QPixmap('hold.png'))
self.setCursor(QtCore.Qt.OpenHandCursor)
self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
scene = QtWidgets.QGraphicsScene()
view = QtWidgets.QGraphicsView(scene)
pixmapItem = PixmapItem()
scene.addItem(pixmapItem)
view.setScene(scene)
view.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment