Joint 派生自QGraphicsItem
void Joint::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
QPainter painter(event->widget());
painter.setPen(QPen(Qt::yellow));
painter.setBrush(QBrush(Qt::yellow));
painter.drawEllipse(0, 0, 500, 500);
update();
}
什么也没画出来。
以前我都是在 ::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /* = 0 */) 里画,现在需要在鼠标按下(之后是移动)时绘画。