0

私はQTに少し慣れていません。Crosshairとを使用して十字線を単純にレンダリングする別のクラスがQPainterありQPenます。この機能を使用したpaint()ところ、ウィンドウ内のある位置に十字線が表示されました。十字線を現在のマウス位置に追従させるにはどうすればよいですか?

これは私のアプローチですが、うまくいきません。私は VoidRealms チュートリアルに従っていました。

void Crosshair::mouseMoveEvent(QGraphicsSceneMouseEvent *event){

   // i want to update the x and y position when the mouse moves
   //x = mouse.x
   //y = mouse.y
   QGraphicsItem::mouseMoveEvent(event);
   update();
 }
4

1 に答える 1