Graphicsitems movement problem



  • 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?



  • 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 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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.