[SOLVED] mousePressEvent in QtQuickView
- 
Hello guys I have a problem here with inheriting from QQuickViewto haveOpenGLcontext in it but overridedmousePressEventdoes not work in this hierarchy
 Don't know why?
 sample code is here
 https://github.com/KDAB/integrating-qq2-with-opengl/blob/master/underlay/myquickview.h
 I tried to overridemousePressEventor other events in this class, but can not get interact with the 3D Scene
 plus I tried to inheriting fromQQuickWindoworQWindowinMeshRendererclassclass MeshRenderer : public QObject, public QQuickWindowbut still overrided events does not work, there is any bug ?thanks in advance 
- 
I got you, but it is not a minimal, because I don't know problem is because of opengl or not 
 btw the underlay sample in kdab repo is really minimalunderlayis usingQQuickViewas base class and uselibforRendering, however we don't need to check thelib/meshrenderer
 if weoverrideanyeventin theQQuickViewclass it can not detect it and no action on itI just added this to the header file protected: void mousePressEvent(QMouseEvent *e) override;and this to cpp file to check the eventvoid MyQuickView::mousePressEvent(QMouseEvent *e) { // qApp->sendEvent(mWindow, e); if (!e->isAccepted()) { qDebug("Hello"); QQuickView::mousePressEvent(e); } }and didn't touch the main.qmlfiletechnically it should work because QQuickViewclass has virtual functions as events that is inherited fromQWindow
 https://doc.qt.io/qt-5/qquickview.html#reimplemented-protected-functionsmake some sense? 
 thanks
- 
main.qml: import QtQuick 2.12 import QtQuick.Window 2.12 import QuickTypes 1.0 MouseItem { visible: true width: 640 height: 480 title: qsTr("Mouse Item test") }main.cpp: #include <QGuiApplication> #include <QQmlApplicationEngine> #include <mouseitem.h> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); qmlRegisterType<MouseItem>("QuickTypes",1,0,"MouseItem"); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }mouseitem.h: #ifndef MOUSEITEM_H #define MOUSEITEM_H #include <QQuickView> class MouseItem : public QQuickView { Q_OBJECT public: MouseItem(); protected: void mousePressEvent(QMouseEvent *e) override; }; #endif // MOUSEITEM_Hmouseitem.cpp: #include "mouseitem.h" #include <QDebug> MouseItem::MouseItem() : QQuickView() { } void MouseItem::mousePressEvent(QMouseEvent *e) { // qApp->sendEvent(mWindow, e); qDebug() << "mousePressEvent"; if (!e->isAccepted()) { qDebug("Hello"); QQuickView::mousePressEvent(e); } }I see the text "mousePressEvent", but I don't see the hello. So the events are happening. 
- 
TBH, I did your method without !e->isAccepted()too, it didn't work
 now it works now, evenvoid MouseItem::mousePressEvent(QMouseEvent *e) { qDebug() << "mousePressEvent"; qDebug("mousePressEvent"); }don't understand 
 but there is another problem that it works, and print the message when click on the window, but it freezes the qml controllers
 this is weird.
 will test other events and will leave comment if there is any problem
- 
- 
This is the more specific question about the mousePressEventproblem
 https://forum.qt.io/topic/113640/why-q-window-events-are-eaten-by-qml-item
- 
Have you tried doing your opengl in a qtquickitem? I wonder if the problem is trying to embed a top level window inside a a qml item. 
- 
The problem is solved 
 please check this
 https://forum.qt.io/topic/113640/solved-why-q-window-events-are-eaten-by-qml-itemthanks 
 
