def paint(self, painter, option, widget=None): painter_inverted = QPainter() brect= QGraphicsProxyWidget.boundingRect(self) invertedColor = QImage(brect.width(),brect.height(),QImage.Format_RGB32) painter_inverted.begin(invertedColor) QGraphicsProxyWidget.paint(self,painter_inverted, option, widget) painter_inverted.end() painter.drawImage(0,0,invertedColor.rgbSwapped())
def testQGraphicsProxyWidget(self): scene = QGraphicsScene() proxy = QGraphicsProxyWidget(None, Qt.Window) widget = QLabel('Widget') proxy.setWidget(widget) proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache) scene.addItem(proxy) scene.setSceneRect(scene.itemsBoundingRect()) view = QGraphicsView(scene) view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform) view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate) view.show() timer = QTimer.singleShot(100, self.app.quit) self.app.exec_()
def __init__(self, parent=None, wFlags=0): QGraphicsProxyWidget.__init__(self, parent, wFlags)
def createItem(minimum, preferred, maximum, name): w = QGraphicsProxyWidget() w.setWidget(QPushButton(name)) w.setMinimumSize(minimum) w.setPreferredSize(preferred) w.setMaximumSize(maximum) w.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) return w
def boundingRect(self): return QGraphicsProxyWidget.boundingRect(self).adjusted(0, 0, 0, 0);
def __init__(self, parent=None): QGraphicsProxyWidget.__init__(self, parent)