Created
October 15, 2018 06:53
-
-
Save eyllanesc/59c676c12467a672f456cab559642b87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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