totem
6th May 2010, 17:32
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 :
void QGraphicsView::mousePressEvent(QMouseEvent *event)
{
// ...
#ifndef QT_NO_RUBBERBAND
if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) {
if (d->sceneInteractionAllowed) {
// Rubberbanding is only allowed in interactive mode.
event->accept();
d->rubberBanding = true;
d->rubberBandRect = QRect();
if (d->scene) {
// Initiating a rubber band always clears the selection.
d->scene->clearSelection();
}
}
} else
#endif
// ...
}
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
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 :
void QGraphicsView::mousePressEvent(QMouseEvent *event)
{
// ...
#ifndef QT_NO_RUBBERBAND
if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) {
if (d->sceneInteractionAllowed) {
// Rubberbanding is only allowed in interactive mode.
event->accept();
d->rubberBanding = true;
d->rubberBandRect = QRect();
if (d->scene) {
// Initiating a rubber band always clears the selection.
d->scene->clearSelection();
}
}
} else
#endif
// ...
}
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