|
a408815041 发表于 2013-9-25 10:34
你这个类 是纯虚类,不能直接用,必须继承,并且把纯虚函数都实现了才能用 ...
大神,具体点呗,我菜鸟呀,我不明白我要怎样去继承和要实现哪些虚函数,
下面这个就可以实现信号与槽机制,好像就多了个Q-OBJECT?
#ifndef PAINTWIDGET_H
#define PAINTWIDGET_H
#include <QGraphicsScene>
#include <QMouseEvent>
#include "shape.h"
#include "line.h"
#include "rect.h"
#include <QtGui>
#include <QtDebug>
#include <QGraphicsItem>
#include <QColor>
#include "ellipseitem.h"
#include "store.h"
class PaintWidget : public QGraphicsScene
{
Q_OBJECT
public:
PaintWidget(QWidget *parent = 0);
enum addColor
{
red,
black,
white,
blue,
green,
yellow
};
enum Contral
{
move,
draw
};
enum Action
{
fangda,
suoxiao,
xuanzhuan,
shanchu
};
public slots:
void setCurrentShape(Shape::Code s);
void setmoveCotral(PaintWidget::Contral c);
void setAction(PaintWidget::Action a);
void getScenePos(QPointF p);
void getSceneEndPos(QPointF endscenepos);
void setAddColor(PaintWidget::addColor d);
void getCunChuSLot();
void getStartPointFfromItem(QPointF startPointF);//得到从item穿过来的两个点进行存储和再现
void getEndPointFfromItem(QPointF endPointF);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
Shape::Code currentShapeCode;
Shape *currentItems;
bool perm;
bool contralmove;
// QPoint pot;
QPointF scenePos;
QPointF m_sceneEndPos;
QColor tempColor;
QPointF m_startPointFfromItem,m_endPointFfromItem;
QList<Shape*> shapeList;
store *cls_store;
int m_desideShape;
// QGraphicsItem *itemForcus;
};
#endif // PAINTWIDGET_H
|
|