jano_alex_es
16th October 2009, 15:01
Hi, I'm trying to solve a problem I was postponing during too much time and now I'm out of ideas.
I have a subclassed QGraphicsTextItem that only receives the drag and drop event when "mousePressEvent" is not implemented. Everything, everything works perfectly (edit text, change the font...) but drag&drop.
#pragma once
#ifndef ITEXTOITEM_H
#define ITEXTOITEM_H
#include "Common/TextoItem.h"
#include <QMenu>
class CITextoItem : public CTextoItem //CTextoItem inherits from QGraphicsTextItem
{
Q_OBJECT
public:
CITextoItem();
~CITextoItem();
private:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
QMenu* m_pMenu;
private slots:
void menuClicked(QAction* pAction);
};
#endif //ITEXTOITEM
void CITextoItem::mousePressEvent(QGraphicsSceneMouseEv ent *event)
{//it should work...
QGraphicsItem::mousePressEvent(event);
}
just in case, the father's class
#pragma once
#ifndef TEXTOITEM_H
#define TEXTOITEM_H
#include "FormElemItem.h"
#include <QGraphicsTextItem>
#include <QObject>
class CTextoItem : public QGraphicsTextItem
{
Q_OBJECT
public:
enum { Type = UserType + 5 };
int type() const
{
// Enable the use of qgraphicsitem_cast with this item.
return Type;
}
CTextoItem();
~CTextoItem();
};
#endif //TEXTOITEM_H
It doesn't mind the code I have inside the mousePressEvent function, drag&drop doesn't work if the function is implemented and it works perfectly if I remove it.
Do you have any clue? right now, I'm out of ideas.
thanks!
I have a subclassed QGraphicsTextItem that only receives the drag and drop event when "mousePressEvent" is not implemented. Everything, everything works perfectly (edit text, change the font...) but drag&drop.
#pragma once
#ifndef ITEXTOITEM_H
#define ITEXTOITEM_H
#include "Common/TextoItem.h"
#include <QMenu>
class CITextoItem : public CTextoItem //CTextoItem inherits from QGraphicsTextItem
{
Q_OBJECT
public:
CITextoItem();
~CITextoItem();
private:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
QMenu* m_pMenu;
private slots:
void menuClicked(QAction* pAction);
};
#endif //ITEXTOITEM
void CITextoItem::mousePressEvent(QGraphicsSceneMouseEv ent *event)
{//it should work...
QGraphicsItem::mousePressEvent(event);
}
just in case, the father's class
#pragma once
#ifndef TEXTOITEM_H
#define TEXTOITEM_H
#include "FormElemItem.h"
#include <QGraphicsTextItem>
#include <QObject>
class CTextoItem : public QGraphicsTextItem
{
Q_OBJECT
public:
enum { Type = UserType + 5 };
int type() const
{
// Enable the use of qgraphicsitem_cast with this item.
return Type;
}
CTextoItem();
~CTextoItem();
};
#endif //TEXTOITEM_H
It doesn't mind the code I have inside the mousePressEvent function, drag&drop doesn't work if the function is implemented and it works perfectly if I remove it.
Do you have any clue? right now, I'm out of ideas.
thanks!