// Базовый классclass WindowItem : public QGraphicsObject{public: WindowItem(QGraphicsItem *parent = 0);};// лева створкаclass LeftGlume : public WindowItem{public: LeftGlume(QGraphicsItem *parent = 0); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);};// правая створкаclass RightGlume : public WindowItem{public: RightGlume(QGraphicsItem *parent = 0); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);protected: void mousePressEvent(QGraphicsSceneMouseEvent *e); void mouseMoveEvent(QGraphicsSceneMouseEvent *e);private: QPointF point;public slots: void slot_resizeGlum();};// верхняя створкаclass TopGlume : public WindowItem{public: TopGlume(QGraphicsItem *parent = 0); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);};// нижняя створкаclass BottomGlume : public WindowItem{public: BottomGlume(QGraphicsItem *parent = 0); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);};
WindowItem::WindowItem(QGraphicsItem *parent) : QGraphicsObject(parent){ setAcceptDrops(true);}// Левая створкаLeftGlume::LeftGlume(QGraphicsItem *parent) : WindowItem(parent){}QRectF LeftGlume::boundingRect() const{ return QRectF(100, 100, 20, 500);}void LeftGlume::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ Q_UNUSED(option); Q_UNUSED(widget); painter->drawRect(100,100,20,500);}// Верхняя створкаTopGlume::TopGlume(QGraphicsItem *parent) : WindowItem(parent){}QRectF TopGlume::boundingRect() const{ return QRectF(100, 100, 500, 20);}void TopGlume::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ Q_UNUSED(option); Q_UNUSED(widget); painter->drawRect(100,100,500,20);}// Нижняя створкаBottomGlume::BottomGlume(QGraphicsItem *parent) : WindowItem(parent){}QRectF BottomGlume::boundingRect() const{ return QRectF(100, 580, 500, 20);}void BottomGlume::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ Q_UNUSED(option); Q_UNUSED(widget); painter->drawRect(100,580,500,20);}// Правая створкаRightGlume::RightGlume(QGraphicsItem *parent) : WindowItem(parent){}QRectF RightGlume::boundingRect() const{ return QRectF(580, 100, 20, 500);}void RightGlume::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ Q_UNUSED(option); Q_UNUSED(widget); painter->drawRect(580,100,20,500);}void RightGlume::mousePressEvent(QGraphicsSceneMouseEvent *e){ if(e->button() == Qt::LeftButton) { point = e->pos(); }}void RightGlume::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ RightGlume *rightG = new RightGlume; int y; y = rightG->pos().y(); setPos(e->scenePos().x() - point.x(), y); connect(rightG,SIGNAL(xChanged()),this,SLOT(slot_resizeGlum())); scene()->update(0,0,1000,1000);}