[PyQt] scene and layers
Christopher M. Nahler
christopher.nahler at papermodels.at
Fri Apr 30 09:31:31 BST 2010
thx. so now I am trying to trying to create my own background but how do
I use drawBackground? In the documentation it says to call it with a
Painter and Rect object. But this code does not seem to work.
Is there an example hidden somewhere in the documentation on how to use
background and foreground layers?
class DesignerScene(QGraphicsScene):
itemInserted = pyqtSignal(DesignerBlock)
itemSelected = pyqtSignal(QGraphicsItem)
def __init__(self, parent=None):
super(DesignerScene, self).__init__(parent)
self.pen = QPen(Qt.black, 1, Qt.SolidLine)
self.brush = QBrush(Qt.white, Qt.SolidPattern)
self.bbrush = QBrush(Qt.lightGray, Qt.SolidPattern)
self.newItem = None
self.startPos = None
self.endPos = None
self.setSceneRect(0, 0, 800, 600)
self.bgPainter = QPainter()
self.bgPainter.setPen(QPen(Qt.red, 1, Qt.SolidLine))
self.bgPainter.drawRect(10, 10, 790, 590)
self.bgRectF = QRectF(0, 0, 800, 600)
#self.setBackgroundBrush(self.bbrush)
self.drawBackground(self.bgPainter, self.bgRectF)
More information about the PyQt
mailing list