0

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
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
EVRR
  • 1
  • 1
  • I have tried to reproduce your problem and I have not been able to do it since it does not generate the problem that you indicate, in the following link is the code: https://gist.github.com/eyllanesc/96a51beb47e753f83b8a35bc87e9ece0, you could provide a [mcve] – eyllanesc Feb 27 '19 at 18:31
  • I dont know if this is the right place to answer back, but thank you for answering! I have done more debugging, and i think the problem is that the creation of InfoBox is done from a function connected to a Signal() in my original code, in sted of from mousePressEvent. Unfortunatlu I did not manage to reproduce the bug in a minimal code. Furthermore, I did not find a sulition to that spesific problem. My solution was to reimplement the ScrollHandDrag according to this post: https://stackoverflow.com/questions/4753681/how-to-pan-images-in-qgraphicsview/5156978#5156978 – EVRR Feb 28 '19 at 15:33
  • As you point out, you should improve your question by providing an [MCVE]. Please read [ask] and review the [tour] – eyllanesc Feb 28 '19 at 15:38

0 Answers0