[Qt-jambi-interest] selecting items with rubberband

Dawid Sip vad at poczta.onet.pl
Thu May 15 20:50:08 CEST 2008


Hi,
Im still working on my Polygonal Path which at the moment uses 
QGraphicsSvgItem for Vertices. At the moment when user presses Shift the 
DragMode for QGraphicsView turns to RubberBand. I want the ability to 
select one, two, ..., all vertices of the MyPolygon under consideration, 
with this Rubber Band. Since the vertices are items, this should work. 
The only thing is, I'm not quite sure how this should work. I give you 
the method from MyPolygon class.

    protected void addVertex(QPointF pos){
        QGraphicsSvgItem Vertex = new QGraphicsSvgItem(){
           
            public java.lang.Object 
itemChange(QGraphicsItem.GraphicsItemChange change,
                    java.lang.Object value){
                System.out.println("State changed. "+"Has been selected 
"+this.isSelected());
                if(this.isSelected())
                    System.out.println("Has been selected ");

                //if(change == 
QGraphicsItem.GraphicsItemChange.ItemSelectedChange)
                    //System.out.println("Has been selected ");

                super.itemChange(change, value);
                return value;
               
            }
        };
        Vertex.setSharedRenderer(renderer);
        Vertex.setZValue(1);
        Vertex.setElementId("layer1");
        
Vertex.setPos(pos.subtract(Vertex.boundingRect().bottomRight().divide(2)));
        scene.addItem(Vertex);
    }

When I add a Vertex the first "System.out.println" is called three times 
(?). But when I stretch the RubberBand over these items nothing happens. 
The second "System.out.println" one is never called. Can somebody please 
give me some tipps?

Dawid


More information about the Qt-jambi-interest mailing list