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. [solved] mouseMoveEvent doesn't respond...

[solved] mouseMoveEvent doesn't respond...

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 8.8k Views
  • 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.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    Hello
    I have a GraphicsViewItem for which I've implemented the mouse doubleclick & mousemove event functions:

    @protected:

    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent( QGraphicsSceneMouseEvent* );
    

    @

    this is what they look like atm:

    @void clickItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
    {
    qDebug("double click!") ;

    }

    void clickItem::mouseMoveEvent( QGraphicsSceneMouseEvent* event )
    {
    qDebug("move");

    }@

    When I attach the item to a scene and display it, the double click function reacts as it should, but the move event function is dead, that is nothing happens... What am I missing?
    Thanks
    Richard

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      A mouse move is only fired if

      • you have mouse button down, or
      • you have enabled mouse tracking.

      Otherwise, you would drown the system in events that are not needed.

      To prevent problems later on, you should always(TM) call the base class event if you reimplement event handlers (or almost all virtual methods, for that matter).

      1 Reply Last reply
      0
      • T Offline
        T Offline
        ThaRez
        wrote on last edited by
        #3

        Hello
        What do you mean by calling the base class event? How to I do this? I just noticed it started working when I implemented the

        @virtual void mousePressEvent (QGraphicsSceneMouseEvent *event);@

        as well. It doesn't have to do anything, just be defined... Any ideas why? Another related problem I have is the now when I draw the items and try to select them, they're selectable only in the upper left corner (from where they're drawn) though both

        @QRectF boundingRect() const;
        QPainterPath shape() const;@

        have been defined to return the whole area... The interesting thing is, that after moving the item (grabbing it from the upper corner) it can be selected from anywhere inside the object (as it should be). Apparently this procedure updates some boundary redraw function, how can I do this manually when the object is drawn?
        Thank you!
        Best regards
        Richard

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          What I mean is, that you need to do this in your implementation:

          @
          void clickItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
          {
          qDebug("double click!") ;
          QGraphicsItem::mouseDoubleClickEvent(event); //assuming that QGraphicsItem is the base class for clickItem
          }
          @

          You do this for all eventhandlers. Depending on your specific use case, you can call it at the beginning, in the middle or at the end of your implementation, but you almost always will want to be making that call.

          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