[Kalzium] Question about QGraphicsView

Carsten Niehaus cniehaus at gmx.de
Tue May 29 13:15:56 CEST 2007


Moin

In Kalzium I created a QGraphicsView with about 3000 QGraphicsItems. When I 
did this with QGraphicRectItems this was pretty fast. Now I *think* I cannot 
use QGRectItems as I need five different type of "rectangles": Four with 
different coulours and one (here is the issue) with a form like this:

------
|     /|          Lets pretent that object is a square ;-) This is a rectangle
|    / |          with a = b = 20 pixel and a line from bottom left to bottom
|  /   |          right.
|/     |
___

You can find a better graphic here:
http://www-linux.gsi.de/~wolle/Schuelerlabor/IMAGES/nuklidkarte-1.jpg

Ok, therefore I implemented it as a QGraphicsPolygonItem with a ctor like 
this:


========================================================
switch (m_type) {
        case alpha:
            m_polygon = QPolygon( QRect(length,length,length,length) );
            break;
        case spontanious:
            m_polygon = QPolygon( QRect(length,length,length,length) );
            break;
        case mulitple:
                //here is the part where I have to draw the strange rectangle.
            break;
        case bplus:
            m_polygon = QPolygon( QRect(length,length,length,length) );
            break;
        case bminus:
            m_polygon = QPolygon( QRect(length,length,length,length) );
            break;
        case stable:
            m_polygon = QPolygon( QRect(length,length,length,length) );
            break;
        default:
            m_polygon = QPolygon( QRect(length,length,length,length) );
            break;
    }
    setPolygon(m_polygon);
    setFlag(QGraphicsItem::ItemIsMovable, false);
    setFlag(QGraphicsItem::ItemIsSelectable, false);
============================================================

Ok, this cannot be the optimum solution, right? Also, this is quite slow, with 
3100 objects it takes 5 seconds to display the dialog (with the QVScene).

So my question: Can I somehow use a QGRectItem and still draw this funky 
rectangle?



Carsten


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kalzium/attachments/20070529/0d95c7b6/attachment-0001.pgp 


More information about the Kalzium mailing list