<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi list,<div>I' having some problem with a custom QGraphicsItem: the option parameter seems to contain wrong values.</div><div>Using the included test code I would expect an <span class="Apple-style-span" style="font-family: Menlo; font-size: 12px; ">option.levelOfDetail value of 0.5 and an option.exposedRect smaller than the entire item rect.</span></div><div><font class="Apple-style-span" face="Menlo">Running the following test cone on Mac OS X Snow Leopard I always get:</font></div><div><font class="Apple-style-span" face="Menlo"><br></font></div><div><font class="Apple-style-span" face="Menlo"><div>option.exposedRect PyQt4.QtCore.QRectF(0.0, 0.0, 1024.0, 1024.0)</div><div>option.levelOfDetail 1.0</div><div><br></div><div>Is it a bug?</div><div><br></div></font></div><div><br></div><div><span class="Apple-style-span" style="font-family: Menlo; font-size: 12px; "># BEGIN CODE #</span></div><div><span class="Apple-style-span" style="color: rgb(210, 0, 168); font-family: Menlo; font-size: 12px; ">import<span style="color: #000000"> sys</span></span></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "><span style="color: #d200a8">from</span> PyQt4 <span style="color: #d200a8">import</span> QtCore, QtGui</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "><span style="color: #d200a8">class</span> GraphicsItem(QtGui.QGraphicsItem):</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; color: rgb(58, 0, 227); "><span style="color: #000000"> data = QtGui.QImage(</span>':/trolltech/qmessagebox/images/qtlogo-64.png'<span style="color: #000000">)</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> data = data.scaled(<span style="color: #3a00e3">1024</span>, <span style="color: #3a00e3">1024</span>, QtCore.Qt.KeepAspectRatio)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> <span style="color: #d200a8">def</span> boundingRect(self):</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> <span style="color: #d200a8">return</span> QtCore.QRectF(self.data.rect())</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> <span style="color: #d200a8">def</span> paint(self, painter, option, widget):</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> <span style="color: #d200a8">print</span> <span style="color: #3a00e3">'option.exposedRect'</span>, option.exposedRect</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> <span style="color: #d200a8">print</span> <span style="color: #3a00e3">'option.levelOfDetail'</span>, option.levelOfDetail</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> exposedData = self.data.copy(option.exposedRect.toAlignedRect())</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> painter.drawImage(option.exposedRect, exposedData)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "><span style="color: #d200a8">if</span> __name__ == <span style="color: #3a00e3">'__main__'</span>:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> app = QtGui.QApplication(sys.argv)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> w = QtGui.QGraphicsView()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> w.resize(<span style="color: #3a00e3">400</span>, <span style="color: #3a00e3">300</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> scene = QtGui.QGraphicsScene(w)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> scene.addItem(GraphicsItem())</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> w.setScene(scene)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> w.scale(<span style="color: #3a00e3">0.5</span>, <span style="color: #3a00e3">0.5</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> w.show()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "> sys.exit(app.exec_())</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Menlo; "># END CODE #</div></div><div><br></div><div><div>Mac OS X 10.6.2 Snow Leopard</div><div>Python<span class="Apple-tab-span" style="white-space: pre; ">        </span>2.6.1 (system python)</div><div>sip<span class="Apple-tab-span" style="white-space: pre; ">        </span>4.9.3</div><div>PyQt4<span class="Apple-tab-span" style="white-space: pre; ">        </span>4.6.2</div><div>Qt<span class="Apple-tab-span" style="white-space: pre; ">        </span>4.6.0 (cocoa 64bit)</div><div><br></div><div><br></div><div>Best regards</div><div><br></div><div>
<div>--</div><div>Antonio Valentino</div><div><br></div></div></div></body></html>