Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.8.4, 5.0.2
-
None
-
qtbase/stable: 0b862e067756132225e33be09670631edd50d944 qt4: 0463c1e6cd26e4b88f433a5598d1bd1544a59212
Description
Run the attached code,
int main(int argc, char* argv[]) { QApplication app(argc, argv); QGraphicsScene scene(0,0,800,480); QGraphicsEllipseItem* item = scene.addEllipse(20,30,120,70); item->setFlag(QGraphicsItem::ItemIsSelectable, true); item->setFlag(QGraphicsItem::ItemIsMovable, true); QGraphicsView view(&scene); view.show(); return app.exec(); }
right click on the ellipse
right click elsewhere outside the ellipse
left/right click on elliipse and drag a bit.
right click on the ellipse again.
On the first right click the ellipse is selected, but after it is dragged it is not selected anymore.
Is that expected/ intentional? If not, does this sound like a valid patch.
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 63a67e0..e51ad2a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7240,7 +7240,8 @@ void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (flags() & ItemIsSelectable) { bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0; - if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) { + if ((event->button() == Qt::LeftButton) && + event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) { // The item didn't move if (multiSelect) { setSelected(!isSelected());