NewLegend
19th November 2010, 23:25
Hello
I created a Node.
I want to deal with the event.
as If the user presses on one of the Node
then, Out a message Or change the color of the Node.
in Node.cpp
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QRadialGradient gradient(-3, -3, 10);
if (option->state & QStyle::State_Sunken) {
gradient.setCenter(4, 4);
gradient.setFocalPoint(4, 4);
gradient.setColorAt(0, Qt::darkBlue);
} else {
gradient.setColorAt(0, Qt::darkBlue);
}
painter->setBrush(gradient);
painter->setPen(QPen(Qt::darkBlue, 0));
painter->drawEllipse(-10, -10, 20, 20);
}
in MainWindow.cpp
Node *node1 = new Node(this);
I created a Node.
I want to deal with the event.
as If the user presses on one of the Node
then, Out a message Or change the color of the Node.
in Node.cpp
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QRadialGradient gradient(-3, -3, 10);
if (option->state & QStyle::State_Sunken) {
gradient.setCenter(4, 4);
gradient.setFocalPoint(4, 4);
gradient.setColorAt(0, Qt::darkBlue);
} else {
gradient.setColorAt(0, Qt::darkBlue);
}
painter->setBrush(gradient);
painter->setPen(QPen(Qt::darkBlue, 0));
painter->drawEllipse(-10, -10, 20, 20);
}
in MainWindow.cpp
Node *node1 = new Node(this);