QGraphicsView - how to disable mouse and keyboard scrolling

In my application, I have a QGraphicsScene with the addition of pixmap, and everything is viewed in a QGraphicsView with scrolling. The program window is smaller than pixmap, and when I press the arrow keys or move the mouse wheel, the pixmap map moves.

How to disable this, so that even if the pixmap is larger than the window, it will not move with the keyboard or mouse if I do not use an event for this?

(I tried to set the interactive property to false, but that didn't work)

+3
source share
3 answers

I believe that the easiest solution would be to set FocusPolicy QGraphicsView to NoFocus, and then process all the key events in the main window.

ui->graphicsView->setFocusPolicy( Qt::NoFocus );
+6

, - QGraphicsView::setSceneRect(), , .

sceneRect() ( ), .

+4

, , , QGraphicsView, .

.

, - , .

0

Source: https://habr.com/ru/post/1709380/


All Articles