<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br><div><br></div><div><br></div><div>class RectItem(QGraphicsRectItem):</div><div>    selectedChange = pyqtSignal(str)</div><div><br></div></div><div>And I got error:</div><div><div>test3.py, line 48, in <module></div><div>    rect.selectedChange.connect(message)</div><div>TypeError: RectItem cannot be converted to PyQt5.QtCore.QObject in this context</div></div><div><br></div>How to solve this?<span class=""><font color="#888888"><div><br clear="all"><div><div>Zdenko</div></div>
<input name="virtru-metadata" type="hidden" value="{"email-policy":{"state":"closed","expirationUnit":"days","disableCopyPaste":false,"disablePrint":false,"disableForwarding":false,"expires":false},"attachments":{}}"></div></font></span></div>
<br></blockquote><div><br></div><div>Zdenko,</div><div><br></div><div><span style="font-size:12.8px">QGraphicsRectItem does not inherit from QObject, while</span> <span style="font-size:12.8px">QGraphicsTextItem does.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">See: <a href="http://stackoverflow.com/questions/4922801/adding-signals-slots-qobject-to-qgraphicsitem-performance-hit">http://stackoverflow.com/questions/4922801/adding-signals-slots-qobject-to-qgraphicsitem-performance-hit</a></span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">The first answer alludes to either inheriting directly from </span><span style="font-size:12.8px">QGraphicsObject, or using multiple inheritance e.g. SomeItem(</span><span style="font-size:12.8px">QGraphicsRectItem, QObject) but i'm not sure this works from python.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">The second answer listed hints at a signal emitting QObject that can emit signals on behalf of the RectItems.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">- mh</span></div></div></div></div>