Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 356
Nyaruko Avatar asked Oct 19 '25 15:10

Nyaruko


1 Answers

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
like image 149
Marco A. Avatar answered Oct 21 '25 06:10

Marco A.