[Qt-interest] QGraphicsItem: rectangular item with holes + best performance?
noname
freekee1 at gmx.de
Mon Feb 15 11:58:52 CET 2010
hi guys,
sorry if the subject doesn't make the topic that clear ... i didn't know
how to make it short really.
i want to create a typical "connect four"-board (rectangular board with
7x6 holes in it).
behind the board, there are QGraphicsItems moving, which you have to see
through those holes in the board!
so far i created the connect-four-board-item using a QGraphicsPathItem
and adding a rectangle and some ellipses to it, and it works quite well.
the only thing is the performance, for example when resizing/scaling the
item:
in my graphics view's resizeEvent i have the following (with my
board-item being part of the scene):
fitInView(scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
now when the graphics view is resized, it takes up to 1 second until the
board item is properly resized, even on quite fast computers.
the only alternative idea i had was to somehow generate a texture for
the board with transparent spots where the holes should be, and display
it on a QGraphicsPixmapItem, but that sounds kind of silly to me ...
maybe anyone can help me out with a hint on how to create such an item
with a better performance (or tell me for sure that there is no way to
make it faster)?
many thanks in advance!
sincerely
julian
More information about the Qt-interest-old
mailing list