<div dir="ltr">We just upgraded to PyQt 5.7 and this is the last problem left to fix, here is a standalone example that I created from our application code:<div><ol><li>Run it; <br></li><li>When the window appears, scroll to the left until you see some rectangles, but scroll such that you see only about half the rectangle (so the other half is outside the viewport). <br></li><li>Then click in the text box to the left of the graphics view. <br></li><li>The clipped rectangle gets drawn over the text box!!! <br></li></ol></div><div>This did not occur in 5.5.1. It seems it has something to do with drawing the background path, but I can't see what we are doing wrong. <br></div><div><div><br></div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><font size="1">from random import random</font></div></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">from PyQt5.QtCore import Qt, QRectF, QPointF</font></div></div><div><div><font size="1">from PyQt5.QtWidgets import QApplication, QGraphicsView, QHBoxLayout, QTextEdit, QGraphicsScene</font></div></div><div><div><font size="1">from PyQt5.QtWidgets import QLabel, QWidget, QGraphicsProxyWidget, QGraphicsObject</font></div></div><div><div><font size="1">from PyQt5.QtWidgets import QStyleOptionGraphicsItem, QGraphicsRectItem</font></div></div><div><div><font size="1">from PyQt5.QtGui import QColor, QBrush, QPainter, QPainterPath, QPen, QPolygonF</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">class MyGraphicsItem(QGraphicsObject):</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> def __init__(self):</font></div></div><div><div><font size="1"> QGraphicsObject.__init__(self)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> self.__default_brush = QBrush(QColor(15, 150, 150), Qt.SolidPattern)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> self.__widget_rect = QGraphicsRectItem(self)</font></div></div><div><div><font size="1"> self.__widget_rect.setPen(QPen(Qt.NoPen))</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> widget = QLabel('hello')</font></div></div><div><div><font size="1"> self.__part_item = QGraphicsProxyWidget(self)</font></div></div><div><div><font size="1"> self.__part_item.setWidget(widget)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> pos_x, pos_y = 33*25*(1 if random() > 0.5 else -1), -10*random()</font></div></div><div><div><font size="1"> self.setPos(QPointF(pos_x, pos_y))</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> widget_rect = QRectF(self.__part_item.boundingRect())</font></div></div><div><div><font size="1"> self.__widget_rect.setRect(widget_rect)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><div><font size="1"> self.__background_path = QPainterPath()</font></div></div></div><div><div><div><font size="1"> trapezoid_poly = QPolygonF(self.__widget_rect.boundingRect().adjusted(-10, -10, 10, 10))</font></div></div></div><div><div><div><font size="1"> self.__background_path.addPolygon(trapezoid_poly)</font></div></div></div><div><div><div><font size="1"> self.__background_path.closeSubpath()</font></div></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> def paint(self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget=None):</font></div></div><div><div><font size="1"> painter.setPen(Qt.NoPen)</font></div></div><div><div><font size="1"> painter.setBrush(self.__default_brush)</font></div></div><div><div><font size="1"> painter.drawPath(self.__background_path)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"> def boundingRect(self) -> QRectF:</font></div></div><div><div><font size="1"> return self.__background_path.boundingRect()</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">class MyScene(QGraphicsScene):</font></div></div><div><div><font size="1"> def __init__(self):</font></div></div><div><div><font size="1"> QGraphicsScene.__init__(self)</font></div></div><div><div><font size="1"> for i in range(10):</font></div></div><div><div><font size="1"> self.addItem(MyGraphicsItem())</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">app = QApplication([])</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">widget = QWidget()</font></div></div><div><div><font size="1">layout = QHBoxLayout()</font></div></div><div><div><font size="1">widget.setLayout(layout)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">view = QGraphicsView()</font></div></div><div><div><font size="1">scene = MyScene()</font></div></div><div><div><font size="1">view.setScene(scene)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">layout.addWidget(QTextEdit())</font></div></div><div><div><font size="1">layout.addWidget(view)</font></div></div><div><div><font size="1"><br></font></div></div><div><div><font size="1">widget.show()</font></div></div><div><div><font size="1">app.exec()</font></div></div></blockquote><div><div><br></div><div><br></div><div>Cheers, </div><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font size="2" style="font-size:small">Oliver</font><div style="font-size:small"><font size="1">Open Source contributions: <a href="http://pubsub.sf.net/" style="color:rgb(17,85,204)" target="_blank">PyPubSub</a>,</font><span style="font-size:x-small"> </span><a href="https://github.com/schollii/nose2pytest" style="color:rgb(17,85,204);font-size:x-small" target="_blank">nose2pytest</a><span style="font-size:x-small">,</span><span style="font-size:x-small"> L</span><a href="http://lua-icxx.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" target="_blank">ua-iCxx</a><span style="font-size:x-small">, </span><a href="http://iof.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" target="_blank">iof</a></div><div style="font-size:small"><font size="1"><a href="http://stackoverflow.com/users/869951/schollii" style="color:rgb(17,85,204)" target="_blank">StackOverflow</a> contributions</font></div></div><div><font size="1"><br></font></div><div></div></div></div></div></div></div></div>
</div></div>