<div dir="ltr">Has anyone tried running the Python code? Anyone replicated the problem on their system? <div><br></div><div>It would be good to know if it is a Qt bug or PyQt bug. I don't have a C++ dev env here but it would be pretty close to the following, any kind soul available out there who could compile and run this and see if the same issue? then I could raise a ticket in Qt bug tracker. </div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>#include <QApplication></div></div><div><div>#include <QtCore></div></div><div><div>#include <QtWidgets></div></div><div><div>#include <QtGui></div></div><div><div><br></div></div><div><div><br></div></div><div><div>class MyGraphicsItem: public QGraphicsObject</div></div><div><div>{</div></div><div><div>public:</div></div><div><div> MyGraphicsItem::MyGraphicsItem()</div></div><div><div> {</div></div><div><div> default_brush = new QBrush(QColor(15, 150, 150), Qt.SolidPattern);</div></div><div><div><br></div></div><div><div> widget_rect = new QGraphicsRectItem(this);</div></div><div><div> widget_rect->setPen(new QPen(Qt::NoPen));</div></div><div><div><br></div></div><div><div> QLabel* widget = new QLabel("hello");</div></div><div><div> part_item = new QGraphicsProxyWidget(this);</div></div><div><div> part_item->setWidget(widget);</div></div><div><div><br></div></div><div><div> float pos_x = 33*25*, pos_y = -10;</div></div><div><div> setPos(QPointF(pos_x, pos_y));</div></div><div><div><br></div></div><div><div> widget_rect->setRect(part_item->boundingRect());</div></div><div><div><br></div></div><div><div> background_path = new QPainterPath();</div></div><div><div> QPolygonF trapezoid_poly(widget_rect->boundingRect().adjusted(-10, -10, 10, 10));</div></div><div><div> background_path->addPolygon(trapezoid_poly);</div></div><div><div> background_path->closeSubpath();</div></div><div><div> }</div></div><div><div><br></div></div><div><div> QRectF boundingRect() const Q_DECL_OVERRIDE { return background_path->boundingRect(); }</div></div><div><div><br></div></div><div><div> void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE</div></div><div><div> {</div></div><div><div> painter->setPen(Qt.NoPen);</div></div><div><div> painter->setBrush(__default_brush);</div></div><div><div> painter->drawPath(__background_path);</div></div><div><div> }</div></div><div><div><br></div></div><div><div>private:</div></div><div><div> QBrush* default_brush;</div></div><div><div> QGraphicsRectItem* widget_rect;</div></div><div><div> QGraphicsProxyWidget* part_item;</div></div><div><div> QPainterPath* background_path;</div></div><div><div><br></div></div><div><div>};</div></div><div><div><br></div></div><div><div><br></div></div><div><div>class MyScene: public QGraphicsScene</div></div><div><div>{</div></div><div><div>public:</div></div><div><div> MyScene() {</div></div><div><div> for (i=0; i<10; i++)</div></div><div><div> addItem(new MyGraphicsItem());</div></div><div><div> }</div></div><div><div>};</div></div><div><div><br></div></div><div><div><br></div></div><div><div>int main(int argc, char *argv[])</div></div><div><div>{</div></div><div><div> QApplication app(argc, argv);</div></div><div><div><br></div></div><div><div> QWidget widget;</div></div><div><div> QHBoxLayout* layout = QHBoxLayout();</div></div><div><div> widget.setLayout(layout)</div></div><div><div><br></div></div><div><div> QGraphicsView* view = new QGraphicsView();</div></div><div><div> MyScene* scene = new MyScene();</div></div><div><div> view->setScene(scene);</div></div><div><div><br></div></div><div><div> layout->addWidget(new QTextEdit());</div></div><div><div> layout->addWidget(view);</div></div><div><div><br></div></div><div><div> widget.show();</div></div><div><div><br></div></div><div><div> return app.exec();</div></div><div><div>}</div></div></blockquote><div><br></div><div>Best, </div><div>Oliver</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="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>
<br><div class="gmail_quote">On Tue, Sep 6, 2016 at 8:14 PM, oliver <span dir="ltr"><<a href="mailto:oliver.schoenborn@gmail.com" target="_blank">oliver.schoenborn@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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(<wbr>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(<wbr>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(<wbr>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.<wbr>boundingRect())</font></div></div><div><div><font size="1"> self.__widget_rect.setRect(<wbr>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.<wbr>boundingRect().adjusted(-10, -10, 10, 10))</font></div></div></div><div><div><div><font size="1"> self.__background_path.<wbr>addPolygon(trapezoid_poly)</font></div></div></div><div><div><div><font size="1"> self.__background_path.<wbr>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.__<wbr>default_brush)</font></div></div><div><div><font size="1"> painter.drawPath(self.__<wbr>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.<wbr>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><span class="HOEnZb"><font color="#888888"><div><div><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">nose2<wbr>pytest</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>
</font></span></div></div>
</blockquote></div><br></div>