QGraphicsView behaving differently when mouse is held over a QGraphicsProxyWidget

253 views Asked by At

I have a pyside2 GUI that uses QGraphicsView.

I use setDragMode(QGraphicsView.ScrollHandDrag) to make the view dragable, but i override the cursor with viewport().setCursor(Qt.ArrowCursor) on mouseReleaseEvent to avoid constantly having the open-hand in stead of the normal arrow cursor. This is explained here: Changing the cursor in a QGraphicsView (in c++)

In the GUI there is also a QGraphicsProxyWidget with a QLabel. When the mouse is placed over the ProxyWidget, the viewport().setCursor(Qt.ArrowCursor) does not work (the moseReleaseEvent is called, so i know that setCursor is called), and when the mouse leaves the ProxyWidget, the open-hand cursor shows in stead of the arrow-cursor.

When the mouse is placed all other places in the QGraphicsView everything is working as expected.

Does anyone know why setCursor is behaving differently when the mouse is placed over a proxyWidget?

In QGraphicsView:

def mouseReleaseEvent(self, event):
    QGraphicsView.mouseReleaseEvent(self, event)
    self.viewport().setCursor(Qt.ArrowCursor)


def infoBoxShow(self, edge, mouse_pos):
    if self.info_box is None:
        self.info_box = VardeInfoBox_v2.InfoBox()
        self.info_box.corresponding_edge = edge
        self.info_box.setPos(mouse_pos)
        self.info_box.setInfoText(edge)

        self.main_scene.addItem(self.info_box)

InfoBox (As you can see i have tried to set some flags without success):

class InfoBox(QGraphicsItem):
Type = QGraphicsItem.UserType + 1

def __init__(self):
    QGraphicsItem.__init__(self)

    self.setFlag(QGraphicsItem.hover)
    self.setZValue(4)

    proxy = QGraphicsProxyWidget(self)

    widget = QLabel("TEST!")
    widget.setAttribute(Qt.WA_TransparentForMouseEvents)
    widget.setWindowModality(Qt.NonModal)

    proxy.setWidget(widget)


    self.corresponding_edge = None
0

There are 0 answers