Nyaruko
Nyaruko

Reputation: 4459

QGraphicsitem emit signal when selected/unselected?

Could any one gives some hint on the easy way to get a signal emitted when the QGraphicsitem is selected/unselected each time?

Upvotes: 4

Views: 1747

Answers (1)

Marco A.
Marco A.

Reputation: 43662

You can use itemChange() to get notified of that (or emit your own signal if you really need it from there):

QVariant QGraphicsItem::itemChange ( GraphicsItemChange change, const QVariant & value ) [virtual protected]

more or less like (pseudocode)

QVariant QGraphicsItemSubclass::itemChange( GraphicsItemChange change, 
                                                 const QVariant &value ) {
    if ( change == QGraphicsItem::ItemSelectedChange ) {
        if (value == true) {
          // Handling selection.. / selection emission

Upvotes: 4

Related Questions