Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MouseEvents not delivering to internalMouseAreas QML 1.1 TouchScreen
Forum Updated to NodeBB v4.3 + New Features

MouseEvents not delivering to internalMouseAreas QML 1.1 TouchScreen

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 652 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sfatima
    wrote on last edited by
    #1

    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 internally

    Qt 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 mode

    I 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 mode

    Can anyone tell what the problem is. Thanks in advance.

    p3c0P 1 Reply Last reply
    0
    • S Sfatima

      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 internally

      Qt 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 mode

      I 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 mode

      Can anyone tell what the problem is. Thanks in advance.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #2

      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.

      157

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved