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. Custom mouseMoveEvent - how to keep default behavior
Forum Updated to NodeBB v4.3 + New Features

Custom mouseMoveEvent - how to keep default behavior

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 254 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.
  • ademmlerA Offline
    ademmlerA Offline
    ademmler
    wrote on last edited by
    #1

    Hi,

    I have overwritten mouseMoveEvent() in my QGraphicsView. So far it does what I need.
    But now the default behavior for "dragMode = ScrollHandDrag" is broken. Means I can't move the "visible section" does not move any longer,
    when I try to click and drag the scene around.

    How do I keep the default behavior also active / available. Aka how to reimplement the defaults.

    void QEnhancedGraphicsView::mouseMoveEvent(QMouseEvent *event)
    {
        //I do my stuff here (Getting coordinates)
        QString text;
        text = QString("%1 X %2").arg(event->pos().x()).arg(event->pos().y());
        QToolTip::showText(this->mapToGlobal(QPoint(event->pos().x(), event->pos().y())), text);
        emit signalSendCoordinates(event->pos());
    
    }
    
    JonBJ Pl45m4P 2 Replies Last reply
    0
    • ademmlerA ademmler

      Hi,

      I have overwritten mouseMoveEvent() in my QGraphicsView. So far it does what I need.
      But now the default behavior for "dragMode = ScrollHandDrag" is broken. Means I can't move the "visible section" does not move any longer,
      when I try to click and drag the scene around.

      How do I keep the default behavior also active / available. Aka how to reimplement the defaults.

      void QEnhancedGraphicsView::mouseMoveEvent(QMouseEvent *event)
      {
          //I do my stuff here (Getting coordinates)
          QString text;
          text = QString("%1 X %2").arg(event->pos().x()).arg(event->pos().y());
          QToolTip::showText(this->mapToGlobal(QPoint(event->pos().x(), event->pos().y())), text);
          emit signalSendCoordinates(event->pos());
      
      }
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #3

      @ademmler

      As @JonB said, add

      QGraphicsView::mouseMoveEvent(event);
      

      below or above your code.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • ademmlerA ademmler

        Hi,

        I have overwritten mouseMoveEvent() in my QGraphicsView. So far it does what I need.
        But now the default behavior for "dragMode = ScrollHandDrag" is broken. Means I can't move the "visible section" does not move any longer,
        when I try to click and drag the scene around.

        How do I keep the default behavior also active / available. Aka how to reimplement the defaults.

        void QEnhancedGraphicsView::mouseMoveEvent(QMouseEvent *event)
        {
            //I do my stuff here (Getting coordinates)
            QString text;
            text = QString("%1 X %2").arg(event->pos().x()).arg(event->pos().y());
            QToolTip::showText(this->mapToGlobal(QPoint(event->pos().x(), event->pos().y())), text);
            emit signalSendCoordinates(event->pos());
        
        }
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @ademmler
        Do you mean calling the base implementation before/after your stuff?

        1 Reply Last reply
        2
        • ademmlerA ademmler

          Hi,

          I have overwritten mouseMoveEvent() in my QGraphicsView. So far it does what I need.
          But now the default behavior for "dragMode = ScrollHandDrag" is broken. Means I can't move the "visible section" does not move any longer,
          when I try to click and drag the scene around.

          How do I keep the default behavior also active / available. Aka how to reimplement the defaults.

          void QEnhancedGraphicsView::mouseMoveEvent(QMouseEvent *event)
          {
              //I do my stuff here (Getting coordinates)
              QString text;
              text = QString("%1 X %2").arg(event->pos().x()).arg(event->pos().y());
              QToolTip::showText(this->mapToGlobal(QPoint(event->pos().x(), event->pos().y())), text);
              emit signalSendCoordinates(event->pos());
          
          }
          
          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #3

          @ademmler

          As @JonB said, add

          QGraphicsView::mouseMoveEvent(event);
          

          below or above your code.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          1
          • ademmlerA Offline
            ademmlerA Offline
            ademmler
            wrote on last edited by
            #4

            Hi Gentlemen,

            thank you - works like a charm! To whom I should give the credit now?

            Regards

            1 Reply Last reply
            0
            • ademmlerA ademmler has marked this topic as solved on
            • ademmlerA ademmler has marked this topic as solved on
            • ademmlerA ademmler has marked this topic as solved on

            • Login

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