Ok!!
I am posting the code here
#ifndef __ITEM_H__
#define __ITEM_H__
#include <QtGui>
#include <Qt>
#include <QGraphicsPolygonItem>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QPolygonF>
{
public :
static int left_mouse_button ;
protected :
// void keyPressEvent(QKeyEvent *keyevent);
};
#endif // __ITEM_H__
#ifndef __ITEM_H__
#define __ITEM_H__
#include <QtGui>
#include <Qt>
#include <QGraphicsPolygonItem>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QPolygonF>
class myitem : public QGraphicsPolygonItem
{
public :
static int left_mouse_button ;
myitem(float x,float y,QGraphicsItem *parent =0 ,QGraphicsScene *scene = 0);
QPolygonF mypolygon ;
protected :
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
void mousePressEvent(QGraphicsSceneMouseEvent *mouseevent);
// void keyPressEvent(QKeyEvent *keyevent);
};
#endif // __ITEM_H__
To copy to clipboard, switch view to plain text mode
{
// if (mouseEvent->button() == Qt::LeftButton)
// myitem::left_mouse_button = 0 ;
}
{
// if (mouseEvent->button() == Qt::LeftButton)
// myitem::left_mouse_button = 1 ;
}
void myitem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
// if (mouseEvent->button() == Qt::LeftButton)
// myitem::left_mouse_button = 0 ;
QGraphicsItem::mouseReleaseEvent(mouseEvent);
}
void myitem::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
// if (mouseEvent->button() == Qt::LeftButton)
// myitem::left_mouse_button = 1 ;
QGraphicsItem::mouseMoveEvent(mouseEvent);
}
To copy to clipboard, switch view to plain text mode
The first time I move the item , it moves but the next time it starts moving from (it feels to me) a random position closer to the point from where it should start and later it disappers though I do not have a single line where I call hide.
I feel its got to do something with the flag. Couldnt find a clue
Bookmarks