Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Simulate mouseMoveEvent not working QT

    General and Desktop
    3
    3
    126
    Loading More Posts
    • 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
      SmithStanley last edited by SmithStanley

      I am trying to grab touch events from one widget and simulate it in another widget.
      The grab and simulate touch events are working fine for mousePressEvent,mouseReleaseEvent.But when I try to
      simualate mouseMoveEvent the corresponding events are not getting in the the destination side.

      void SimulateManager::showWidgets()
      {

      Source.show();
      Destination.show();

      connect(&Source, SIGNAL(sigMousePress(QMouseEvent *)), this, SLOT(slotMousePress(QMouseEvent *)));
      connect(&Source, SIGNAL(sigMouseMove(QMouseEvent *)), this, SLOT(slotMouseMove(QMouseEvent *)));
      }

      void SourceWidget:: mouseMoveEvent(QMouseEvent *event)
      {
      emit sigMouseMove(event);
      }

      void SourceWidget::mousePressEvent(QMouseEvent *event)
      {
      emit sigMousePress(event) LiteBlue;

      }

      void SimulateManager:: slotMousePress(QMouseEvent *event)
      {

      QPoint pPoint(event->pos().x(),event->pos().y());
      QMouseEvent mouseEvent( (QEvent::MouseButtonPress),pPoint, Qt::LeftButton, Qt::NoButton,Qt::NoModifier );
      QCoreApplication::sendEvent(&Destination, &mouseEvent);
      }

      void SimulateManager:: slotMouseMove(QMouseEvent *event)
      {
      QPoint pPoint(event->pos().x(),event->pos().y());
      QMouseEvent mouseEvent( (QEvent::MouseMove),pPoint, Qt::LeftButton, Qt::NoButton,Qt::NoModifier );
      QCoreApplication::sendEvent(&Destination, &mouseEvent);

      }

      void DesitinationWidget:: mouseMoveEvent(QMouseEvent *event)
      {
      qDebug()<<Q_FUNC_INFO;
      }

      void DesitinationWidget::mousePressEvent(QMouseEvent *event)
      {
      qDebug()<<Q_FUNC_INFO;
      }

      The above code is used for grab and simulate. Basically the (QEvent::MouseMove)+ (Qt::LeftButton) is for scrolling a tablewidget.
      QCoreApplication::sendEvent returns success.Can any one help me with this.

      raven-worx 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi and welcome to the forums
        I wonder if
        https://doc.qt.io/qt-5/qwidget.html#mouseTracking-prop
        has any part in this ?

        since the issues is with mouseMoveEvent and its default off

        1 Reply Last reply Reply Quote 0
        • raven-worx
          raven-worx Moderators @SmithStanley last edited by

          @SmithStanley
          so many pitfals with this rather ugly approach to achieve what you want.
          the pos is in the source widgets coordinate system.
          scrolling is handled by the scrollbar widget (which is a child of the item widget)

          to sync the scrollbars simply connect the values of them.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply Reply Quote 3
          • First post
            Last post