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:
private slots:
void menuClicked
(QAction* pAction
);
};
#endif //ITEXTOITEM
#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
To copy to clipboard, switch view to plain text mode
{//it should work...
}
void CITextoItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{//it should work...
QGraphicsItem::mousePressEvent(event);
}
To copy to clipboard, switch view to plain text mode
just in case, the father's class
#pragma once
#ifndef TEXTOITEM_H
#define TEXTOITEM_H
#include "FormElemItem.h"
#include <QGraphicsTextItem>
#include <QObject>
{
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
#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
To copy to clipboard, switch view to plain text mode
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!
Bookmarks