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. Graphicsitems movement problem
Qt 6.11 is out! See what's new in the release blog

Graphicsitems movement problem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.1k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    hi! How can I solve this problem:
    There are QGraphicsView * view, QGraphicsScene *scene, QGraphicsItem *item;
    in the view's drawbackground() function I draw with qpainter layer#1;
    on scene i'm adding custom items - this is layer#2;

    also in view.h I reimplemented following function for scaling, zooming etc:
    @ void drawBackground(QPainter *p, const QRectF &rect);
    void mouseMoveEvent(QMouseEvent *event); // problem for items
    // void mouseMoveEvent(QMouseEvent *event); in this case problem for view
    void wheelEvent(QWheelEvent *event);
    void keyPressEvent(QKeyEvent *e);
    @
    Problem:
    when mouseMoveEvent() is enabled, items lose their ability to respond on mouseevents such as movement , selecting and etc.

    how can I leave (dont't erase) mouseMoveEvent() in view.h and at the same time to be able move my custom items?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi!

      Did you reimplement mouseMoveEvent in QGraphicsItem or in QGraphicsScene?
      Could you paste your code.

      If in QGraphicsScene, you're probably missing:
      @QGraphicsScene::mouseMoveEvent(event);@

      Regards,
      Jake

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        [quote author="Jake007" date="1355466601"]Hi!

        Did you reimplement mouseMoveEvent in QGraphicsItem or in QGraphicsScene?
        Could you paste your code.

        If in QGraphicsScene, you're probably missing:
        @QGraphicsScene::mouseMoveEvent(event);@

        Regards,
        Jake[/quote]

        thank you , it works

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Please mark post as solved ( perpend [SOLVED] to title).

          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