The enterEvent and leaveEvent of QGraphicsView do not match the actual show area well
-
I'm using PySide6. I created a custom QGraphicsView and I rewrite the enterEvent () function and the leaveEvent() function. But the actual working area does not match the visual area.

Parts of the code:class LossCurve(QGraphicsView): def __init__(self, parent=None): super().__init__(parent) self.setScene(QGraphicsScene(self)) self.setDragMode(QGraphicsView.NoDrag) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setRenderHint(QPainter.Antialiasing) self.chart = QChart() self.chart.setAcceptHoverEvents(True) self.chart.legend().hide() self.series = QLineSeries() self.chart.addSeries(self.series) self.x_axis = QValueAxis() self.x_axis.setLabelFormat("%i") self.y_axis = QValueAxis() self.chart.addAxis(self.x_axis, Qt.AlignBottom) self.series.attachAxis(self.x_axis) self.chart.addAxis(self.y_axis, Qt.AlignLeft) self.series.attachAxis(self.y_axis) self.scene().addItem(self.chart) self.x_legend = QGraphicsSimpleTextItem(self.chart) self.x_legend_text = '轮:' self.x_legend.setText(self.x_legend_text) self.y_legend = QGraphicsSimpleTextItem(self.chart) self.y_legend_text = '损失:' self.y_legend.setText(self.y_legend_text) self._callouts = [] self._tooltip = Callout(self.chart) # self.series.clicked.connect(self.keep_callout) self.series.hovered.connect(self.draw_tooltip) self.setMouseTracking(True) def enterEvent(self, event): print('enter........') def leaveEvent(self, event): print('leave........') -
Hi,
Do you have the same issue with an empty scene ?
Which exact version of PySide6 are you using ?
On which platform ?
How did you install it ? -
I'm using PySide6. I created a custom QGraphicsView and I rewrite the enterEvent () function and the leaveEvent() function. But the actual working area does not match the visual area.

Parts of the code:class LossCurve(QGraphicsView): def __init__(self, parent=None): super().__init__(parent) self.setScene(QGraphicsScene(self)) self.setDragMode(QGraphicsView.NoDrag) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setRenderHint(QPainter.Antialiasing) self.chart = QChart() self.chart.setAcceptHoverEvents(True) self.chart.legend().hide() self.series = QLineSeries() self.chart.addSeries(self.series) self.x_axis = QValueAxis() self.x_axis.setLabelFormat("%i") self.y_axis = QValueAxis() self.chart.addAxis(self.x_axis, Qt.AlignBottom) self.series.attachAxis(self.x_axis) self.chart.addAxis(self.y_axis, Qt.AlignLeft) self.series.attachAxis(self.y_axis) self.scene().addItem(self.chart) self.x_legend = QGraphicsSimpleTextItem(self.chart) self.x_legend_text = '轮:' self.x_legend.setText(self.x_legend_text) self.y_legend = QGraphicsSimpleTextItem(self.chart) self.y_legend_text = '损失:' self.y_legend.setText(self.y_legend_text) self._callouts = [] self._tooltip = Callout(self.chart) # self.series.clicked.connect(self.keep_callout) self.series.hovered.connect(self.draw_tooltip) self.setMouseTracking(True) def enterEvent(self, event): print('enter........') def leaveEvent(self, event): print('leave........')@feiyuhuahuo I do not reproduce the problem, could you provide a complete and verifiable example. In my test I had to remove the callout code. I use Linux with PySide6 6.1.2
-
@SGaist @eyllanesc I found the reason. The two arrows are in a hoverd window and the window is frameless and has a transparent background. The real window size is showed in the below picture. So it affects the activation area of the
QGraphicsView.