MouseEvents not delivering to internalMouseAreas QML 1.1 TouchScreen
-
Hi
i am developing on a touch Screen, but i have a particular problem for QML 1.1 where my generated MouseEvents are not being delivered to internal MouseAreas of a QML file. The outerMouseArea captures event but does not send it internallyQt Code: Switch view
Rectangle {
id: screen;/* Content */ width: 800; height: 480; Rectangle{ id:header width: 300 height: 42 color: "blue" anchors.right: parent.right anchors.bottom: parent.bottom anchors.rightMargin: 10 anchors.bottomMargin: 10 MouseArea{ id: headerMouse width: header.width height: header.height x: header.x y: header.y onEntered: { console.log("on Entered"); console.log("mouseArea x", x); console.log("mouseArea y", y); console.log("mouseArea width", width); console.log("mouseArea height", height); } onPressed: { console.log("onClicked inside X", mouseX); console.log("onClicked inside Y", mouseY); mouse.accepted = false; } }
}
Rectangle{ id:header2 width: 300 height: 42 color: "yellow" anchors.left: parent.left anchors.leftMargin: 10 anchors.top: parent.top anchors.topMargin: 10 MouseArea{ id: header2Mouse width: header2.width height: header2.height x: header2.x y: header2.y onEntered: { console.log("on Entered in header 2"); console.log("mouseArea x", x); console.log("mouseArea y", y); console.log("mouseArea width", width); console.log("mouseArea height", height); } onPressed: { console.log("onClicked inside header 2", mouseX); console.log("onClicked inside header 2", mouseY); mouse.accepted = false; } }
}
MouseArea
{
anchors.fill: parent
onEntered:
{
console.log("area parent X", mouseX);
console.log("area parent Y", mouseY);
}} onPressed: { mouse.accepted = false; }
}
}
To copy to clipboard, switch view to plain text modeI am using seperate thread to generate MouseEvents
Qt Code: Switch view
QCursor::setPos(position.x, position.y);
QPoint absoluteWidgetPosition = d->getViewer()->mapToGlobal(QPoint(0, 0));
int relativeX = position.x - absoluteWidgetPosition.x();
int relativeY = position.y - absoluteWidgetPosition.y();if(newState == PANEL_RELEASED) { qApp->postEvent(view, new QMouseEvent(QEvent::MouseButtonRelease, QPoint(relativeX,relativeY), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); qDebug() << "QEvent::MouseButtonPress Panel released: x" << relativeX << "y:" << relativeY; } else if(newState ==PANEL_PRESSED) { qApp->postEvent(view, new QMouseEvent(QEvent::MouseButtonPress, QPoint(relativeX,relativeY), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); qDebug() << "QEvent::MouseButtonPress Panel pressed: x" << relativeX << "y:" << relativeY ; }
To copy to clipboard, switch view to plain text mode
I am capturing events in a derived class of QtQuick1ApplicationViewe
Qt Code: Switch view
#include "myview.h"
#include "qdebug.h"MyView::MyView(QWidget *parent) :
QtQuick1ApplicationViewer(parent)
{
}bool MyView::event(QEvent *e)
{
if((e->type() == QEvent::MouseButtonPress) ||
(e->type() == QEvent::MouseButtonRelease))
return QWidget::event(e);
else
return QtQuick1ApplicationViewer::event(e);}
void MyView::mousePressEvent(QMouseEvent *evt)
{
qDebug() << "MouseEvent Press type" << evt->type();QtQuick1ApplicationViewer::mousePressEvent(evt);
}
void MyView::mouseReleaseEvent(QMouseEvent *evt)
{
qDebug() << "MouseEvent Release type" << evt->type();QtQuick1ApplicationViewer::mouseReleaseEvent(evt);
}
To copy to clipboard, switch view to plain text modeCan anyone tell what the problem is. Thanks in advance.
-
Hi @Sfatima,
I don't know about Qt Quick 1.1 but in Qt Quick 2.0 and onwards you have propagateComposedEvents. Setting it allows the mouse events to propagate to other areas.
BTW QtQuick 1.x is deprecated now.