Hello dear QT-Community,

i am developing kind of a game and encounter the following problem: I have a GraphicsScene which represents the map of the game. With a GraphicsView I display this map. Now I want to remove the scrollbars (haven't done this yet but can't be that hard) and use the mouse to scroll now. At the right side of the Map there is a Panel which displays details about the current GraphicsItem. I think everyone who ever played a strategy game on PC can imagine what I mean
So scrolling shall occur when the mouse reaches one of the edges of my GraphicsView widget. And of course the Cursor must not be allowed to leave that widget. Unfortunately i was not able to implement this in a elegant way.

When I try something like this, my Cursor is always removed from the View widget when I try to enter it. I set it in the center of the View before. But it gets thrown out immediately.

Qt Code:
  1. void MapView::mouseMoveEvent(QMouseEvent *event){
  2. if (event->type() & QEvent::Leave){
  3. QPoint newPos(event->x(), event->y());
  4. this->mapToGlobal(newPos);
  5. this->cursor().setPos(newPos);
  6. QPointF newCenter = currentCenter();
  7. centerOn(newCenter.x() + this->width()/10, newCenter.y() + this->height()/10);
  8. }
To copy to clipboard, switch view to plain text mode 

Any ideas are very welcome.

Regards,
Simon