QGraphicsView - how to disable mouse and keyboard scrolling
In my application I have QGraphicsScene with pixmap added and all is viewed in QGraphicsView with scrollbars off.
The program window is smaller then pixmap and when I press arrow keys or move mouse wheel the pixmap is being moved.
How do I disable that so even if the pixmap is bigger than window it won't be moved by keyboard or mouse unless I use my events for that?
(I tried to set interactive property to false but that didn't work)
Re: QGraphicsView - how to disable mouse and keyboard scrolling
I believe the easiest solution would be to set FocusPolicy of QGraphicsView to NoFocus and then process all key events in main window.
Code:
ui->graphicsView->setFocusPolicy( Qt::NoFocus );
Re: QGraphicsView - how to disable mouse and keyboard scrolling
mouse wheel events still go thru tho :(
Re: QGraphicsView - how to disable mouse and keyboard scrolling
use eventFilter() and filter the mouse events ...
Code:
{
if(ob
== item_need_filter
&& e
->type
() == QEvent::MousePress /**any event u want to filter**/) { .......
}
return true;
}
return QWidget::eventFilter(ob, e
);
}