5
from PySide.QtGui import QGraphicsScene, QGraphicsRectItem, QGraphicsView, QApplication, QBrush, QColor
6
from PySide.QtCore import QTimer
7
from helper import UsesQApplication
9
qgraphics_item_painted = False
11
class RoundRectItem(QGraphicsRectItem):
13
def __init__(self, x, y, w, h):
14
QGraphicsRectItem.__init__(self, x, y, w, h)
16
def paint(self, painter, qstyleoptiongraphicsitem, qwidget):
17
global qgraphics_item_painted
18
qgraphics_item_painted = True
21
class QGraphicsItemTest(UsesQApplication):
23
def createRoundRect(self, scene):
24
item = RoundRectItem(10, 10, 100, 100)
25
item.setBrush(QBrush(QColor(255, 0, 0)))
32
def test_setParentItem(self):
33
global qgraphics_item_painted
35
scene = QGraphicsScene()
37
view = QGraphicsView(scene)
39
rect = self.createRoundRect(scene)
41
QTimer.singleShot(1000, self.quit_app)
43
self.assert_(qgraphics_item_painted)
46
if __name__ == '__main__':