Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catching the selectionChanged() signal of a QGraphicsScene

Tags:

qt

qt4

I am trying to catch the signal that indicates that the user has used the rubberband to select a region. I tried this:

  QGraphicsScene* scene = new QGraphicsScene();

  connect(scene, SIGNAL(selectionChanged()), this, SLOT(SelectionChanged()));
  this->graphicsView->setScene(scene);
  this->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);

but my SelectionChanged() slot is never called. Any ideas how to do this?

like image 354
David Doria Avatar asked Nov 30 '25 21:11

David Doria


1 Answers

In order the signal selectionChanged to be emitted whenever some items in the scene get selected. In order to get selected the flag QGraphicsItem::ItemIsSelectable should have been set.

Are you sure the items are selectable?

like image 78
pnezis Avatar answered Dec 05 '25 14:12

pnezis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!