Seite 1 von 1

QGraphicsScene items für QGraphicsProxyWidgets

Verfasst: 12. April 2010 13:06
von mgleich
Hallo,

ich füge in ein QGraphicsScene mehrere QGraphicsProxyWidgets ein. Wenn ich innerhalb eines dieser Widgets dann mit der Maus klicke und das im mousePressEvent() mitbekomme gibt items(event.scenePos()) aber kein QGraphicsItem zurück. Wenn ich mir die Event Position und die boundingRects anschaue kann ich keinen Fehler feststellen:

Code: Alles auswählen

void EDGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* aEvent)
{
    QPointF tPos=aEvent->scenePos();

    EDEBUG("event pos: "<<tPos);
    // => event pos: [ 335.000000,218.000000 ]

    QList<QGraphicsItem*> tItems=items();

    EDEBUG("item count "<<tItems.count());
    // => item count 2

    foreach(QGraphicsItem* tItem, tItems)
    {
        EDEBUG("bounding rect "<<tItem->boundingRect());
        // => 0: bounding rect [ -4.000000,-20.000000,248.000000,440.000000 ]
        // => 1: bounding rect [ -4.000000,-20.000000,248.000000,440.000000 ]

        EDEBUG("bounding scene rect "<<tItem->sceneBoundingRect());
        // => 0: bounding scene rect [ 464.000000,204.000000,248.000000,440.000000 ]
        // => 1: bounding scene rect [ 191.000000,202.000000,248.000000,440.000000 ]
    }

    tItems=items(tPos);

    EDEBUG("item count "<<tItems.count());
    // => item count 0
}
EDEBUG macht dabei nichts anderes als es in QString umzuwandeln und dann dem entsprechend auszugeben. Die resultierenden Ausgaben sind als Kommentar unter der entsprechenden Zeile.