I'm stuck with the following problem :

I have a scene with several QGraphicsItems-derived instances. I make a first selection, then I want to extend it using CTRL-key and rubber band. The problem is that QGraphicsView does not seem to support extended selection due to following code :

in qgraphicsview.cpp :

Qt Code:
  1. void QGraphicsView::mousePressEvent(QMouseEvent *event)
  2. {
  3.  
  4. // ...
  5.  
  6. #ifndef QT_NO_RUBBERBAND
  7. if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) {
  8. if (d->sceneInteractionAllowed) {
  9. // Rubberbanding is only allowed in interactive mode.
  10. event->accept();
  11. d->rubberBanding = true;
  12. d->rubberBandRect = QRect();
  13. if (d->scene) {
  14. // Initiating a rubber band always clears the selection.
  15. d->scene->clearSelection();
  16. }
  17. }
  18. } else
  19. #endif
  20.  
  21. // ...
  22. }
To copy to clipboard, switch view to plain text mode 

As you see, "Initiating a rubber band always clears the selection". So I tried to overload my scene's clearSelection() method to have my word on it, but unfortunately it's not a virtual method and thus it's not called.

I'd prefer a check at scene's level, not at item's level (indeed, i could check for QApplication::keyboardModifiers() in the itemChange() method of each item, but it's kinda intrusive)

Anybody faced the same problem ?

Thanks in advance for your answers