class CloudNode : public Node
{
public:
CloudNode(GraphWidget *graphWidget);
protected:
private:
};
CloudNode::CloudNode(GraphWidget *graphWidget) : Node(graphWidget)
{
qDebug() << "Creating CloudNode";
cloudimage
= new QImage();
// = new QImage(); bool loadsuccess = cloudimage->load("./images/background.png");
qDebug() << "CloudNode loaded image = " << loadsuccess;
setFlag(ItemIsMovable);
setCacheMode(DeviceCoordinateCache);
pixmap
= QPixmap::fromImage(*cloudimage, Qt
::OrderedAlphaDither);
}
{
qDebug() << "CloudNode::paint";
p->drawPixmap(0, 0, pixmap);
}
QRectF CloudNode
::boundingRect() const {
int adjust = 0;
QRectF noderect
(-adjust,
-adjust, cloudimage
->width
() +10, cloudimage
->height
()+10);
//qDebug() << "CloudNode width " << noderect.width() << " height " << noderect.height();
return noderect;
}
{
update();
qDebug() << "CloudNode mouse x " << event->pos().x() << " y " << event->pos().y();
}
class CloudNode : public Node
{
public:
CloudNode(GraphWidget *graphWidget);
protected:
void paint( QPainter *, const QStyleOptionGraphicsItem *option, QWidget *widget );
QRectF boundingRect() const;
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
QImage *cloudimage;
QPixmap pixmap;
};
CloudNode::CloudNode(GraphWidget *graphWidget) : Node(graphWidget)
{
qDebug() << "Creating CloudNode";
cloudimage = new QImage(); // = new QImage();
bool loadsuccess = cloudimage->load("./images/background.png");
qDebug() << "CloudNode loaded image = " << loadsuccess;
setFlag(ItemIsMovable);
setCacheMode(DeviceCoordinateCache);
pixmap = QPixmap::fromImage(*cloudimage, Qt::OrderedAlphaDither);
}
void CloudNode::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget * )
{
qDebug() << "CloudNode::paint";
p->drawPixmap(0, 0, pixmap);
}
QRectF CloudNode::boundingRect() const
{
int adjust = 0;
QRectF noderect(-adjust, -adjust, cloudimage->width() +10, cloudimage->height()+10);
//qDebug() << "CloudNode width " << noderect.width() << " height " << noderect.height();
return noderect;
}
void CloudNode::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
update();
QGraphicsItem::mousePressEvent(event);
qDebug() << "CloudNode mouse x " << event->pos().x() << " y " << event->pos().y();
}
To copy to clipboard, switch view to plain text mode
Bookmarks