Vertical scrolling with the mouse wheel in QGraphicsView in versions 5.15.1 and 6.6.1
In version 5.15.1, if the mouse cursor is over a widget (as in the example below - QTextEdit), there is scrolling for the entire QGraphicsView. In version 6.6.1, scrolling only occurs when the mouse cursor is not over QTextEdit. Is it possible to achieve the behavior that was present in version 5.15.1 ?
Code:
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QWidget>
#include <QGraphicsProxyWidget>
MainWindow
::MainWindow(QWidget *parent
) , ui(new Ui::MainWindow)
{
ui->setupUi(this);
setCentralWidget(graphicsView);
graphicsView
->setFrameShape
(QFrame::NoFrame);
QGraphicsProxyWidget* proxyWidget = new QGraphicsProxyWidget();
proxyWidget->setWidget(textEdit);
scene->addItem(proxyWidget);
textEdit->move(-100,500);
}
Re: Vertical scrolling with the mouse wheel in QGraphicsView in versions 5.15.1 and 6
Quote:
Originally Posted by
VVS
In version 5.15.1, if the mouse cursor is over a widget (as in the example below - QTextEdit), there is scrolling for the entire QGraphicsView. In version 6.6.1, scrolling only occurs when the mouse cursor is not over QTextEdit. Is it possible to achieve the behavior that was present in version 5.15.1 ?
Code:
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QWidget>
#include <QGraphicsProxyWidget>
MainWindow
::MainWindow(QWidget *parent
) , ui(new Ui::MainWindow)
{
ui->setupUi(this);
setCentralWidget(graphicsView);
graphicsView
->setFrameShape
(QFrame::NoFrame);
QGraphicsProxyWidget* proxyWidget = new QGraphicsProxyWidget();
proxyWidget->setWidget(textEdit);
scene->addItem(proxyWidget);
textEdit->move(-100,500);
}
Hello,
I had something similar.
What I did was define a new class daughter of QTextEdit, make sure that its parent is the QGraphicView, and redefine wheelEvent so that it calls the parent's wheelEvent.
In python :
Code:
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
def wheelEvent(self, event):
self.parent.wheelEvent(event)
return True