I'm trying to change the cursor of a QGraphicsView
while the ScrollHandDrag
is on, but it doesn't seem to work.
I can change the cursor if I disable the ScrollHandDrag
but not while it's active, I don't see what I could possibly be doing wrong...
Bellow is a portion of code that reproduce the problem:
QApplication app(argc, argv);
QGraphicsScene scene;
QRect rectangle(-8, -4, 100, 100);
QPen pen(Qt::blue, 1, Qt::SolidLine);
scene.addRect(rectangle, pen);
scene.setBackgroundBrush(Qt::white);
QGraphicsView vue(&scene);
vue.setFixedSize(250, 250);
//vue.setDragMode(QGraphicsView::ScrollHandDrag);
vue.setCursor(Qt::CrossCursor);
vue.show();
return app.exec();
void MyQGraphicsView::mouseReleaseEvent(QMouseEvent *event) { QGraphicsView::mouseReleaseEvent(event); if (m_click) { viewport()->setCursor(Qt::CrossCursor); } else { viewport()->unsetCursor(); } }
but instead of having a hand cursor, which is what I would expect, I have the arrow cursor. My question is: do I have to set all the different cursors or is there a function that would just undo the setCursor? – Stlaurent