qt - Moving QGraphicsPixmapItem and getting itemChange events -


i have qgraphicspixmapitem move around setflag(qgraphicsitem::itemismovable), activated itemsendsscenepositionchanges flag on item function itemchange(graphicsitemchange change, const qvariant &value) isn't called when move item around.

any sugestions?

here code itemchange():

#include "graphicspixmapitem.h"  graphicspixmapitem::graphicspixmapitem(qgraphicsitem *parent, qgraphicsscene *scene)   : qgraphicspixmapitem(parent) {  }  void graphicspixmapitem::mousepressevent(qgraphicsscenemouseevent *event) {   //m_clicked_signal(this);   //  emit clicked(); } void graphicspixmapitem::mousereleaseevent(qgraphicsscenemouseevent *event) {   //m_clicked_signal(this);     emit clicked(); }  #include <qdebug> qvariant graphicspixmapitem::itemchange(graphicsitemchange change, const qvariant &value) {     if (change == itempositionchange) {             qdebug() << "position changed";         }     return qgraphicsitem::itemchange(change, value); } 

and code setflags:

qpixmap trackinfo(":/images/screencontacts.png");     buf = addpixmap(trackinfo);     buf->setpos(0, 40);     buf->setflag(qgraphicsitem::itemismovable);     buf->setflag(qgraphicsitem::itemsendsscenepositionchanges);     buf->setcachemode(qgraphicsitem::itemcoordinatecache); 

have tried calling default implementation of qgraphicsitem::mousepressevent , qgraphicsitem::mousereleaseevent on item's mousepressevent , mousereleaseevent?

if don't call them, suspect won't able move item mouse, since aren't letting qt know when item clicked/released.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -