iadfuqgraphicsitem.cpp - I subclassed QGraphicsPixmapItem
#include <QtGui>
#include "iadfuqgraphicsitem.h"
setAcceptDrops (false);
setAcceptsHoverEvents(true);
setEnabled(true);
setVisible(true);
setZValue(1);
}
QMessageBox::information(0, tr
("!!!!!!!"), tr
("Y!!!!"));
}
}
}
#include <QtGui>
#include "iadfuqgraphicsitem.h"
IADFUQGraphicsItem::IADFUQGraphicsItem(QGraphicsItem * parent) :
QGraphicsPixmapItem(parent) {
setAcceptDrops (false);
setAcceptsHoverEvents(true);
setEnabled(true);
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable
| QGraphicsItem::ItemIgnoresTransformations);
setVisible(true);
setZValue(1);
}
void IADFUQGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
QMessageBox::information(0, tr("!!!!!!!"), tr("Y!!!!"));
}
void IADFUQGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
}
void IADFUQGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) {
}
To copy to clipboard, switch view to plain text mode
iadfuqgraphicsitem.h
#ifndef IADFUQGRAPHICSITEM_H
#define IADFUQGRAPHICSITEM_H
#include <QGraphicsPixmapItem>
#include <QObject>
Q_OBJECT
public:
protected:
};
#endif
#ifndef IADFUQGRAPHICSITEM_H
#define IADFUQGRAPHICSITEM_H
#include <QGraphicsPixmapItem>
#include <QObject>
class QGraphicsSceneMouseEvent;
class IADFUQGraphicsItem : public QObject, public QGraphicsPixmapItem {
Q_OBJECT
public:
IADFUQGraphicsItem(QGraphicsItem* parent = 0);
protected:
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
};
#endif
To copy to clipboard, switch view to plain text mode
is this the right way to create a new IADFUQGraphicsItem?
IADFUQGraphicsItem *item = qobject_cast<IADFUQGraphicsItem *>(someQGraphicsPixmapItem);
IADFUQGraphicsItem *item = qobject_cast<IADFUQGraphicsItem *>(someQGraphicsPixmapItem);
To copy to clipboard, switch view to plain text mode
Bookmarks