Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simulate mouseMoveEvent not working QT

Simulate mouseMoveEvent not working QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 475 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
    SmithStanley
    wrote on last edited by SmithStanley
    #1

    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-worxR 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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
      0
      • S 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-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @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
        3

        • Login

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