在 QGraphicsView 中禁用鼠标指针

Disable mouse pointer in QGraphicsView

我想在 QGraphicsView 中禁用鼠标指针。

下面的例子需要添加哪一行代码?

import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QGraphicsView


class GraphicsWindow(QGraphicsView):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.showFullScreen()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.close()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    graphics_window = GraphicsWindow()
    graphics_window.show()
    sys.exit(app.exec_())

Qt::BlankCursor一个blank/invisible光标,通常在需要隐藏光标形状时使用。

import sys
from PyQt5.QtCore    import Qt
from PyQt5.QtWidgets import QApplication, QGraphicsView

class GraphicsWindow(QGraphicsView):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.showFullScreen()

        self.setCursor(Qt.BlankCursor)          # < ------

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.close()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    graphics_window = GraphicsWindow()
    graphics_window.show()
    sys.exit(app.exec_())