0
我有一個從QGraphicsScene繼承的類。我在這個類中有一個mouseMoveEvent。基於鼠標移動,我通過信號發送座標到主窗口。我在主窗口中有多個GraphicViews。基於接收信號的場景,我使用QGraphicsTextItem顯示場景座標。 問題是,當我移出場景區域時,我無法隱藏QGraphicsTextItem。 有人可以爲我解決這個問題嗎?檢測鼠標不在QGraphicsScene
Class Scene::QGraphicsScene
{
void MouseMoveEvent(QGraphicsSceneMouseEvent *Event)
{
int XPos = event.x();
int YPos = event.y();
emit SignalPos(XPos,YPos);
}
}
//In Main Window
connect(scene1,SignalPos(int,int),this,SlotPos1(int,int);
//Similarly for scene2,scene3,scene4
void MainWindow::SlotPos(int X, int Y)
{
m_qgtxtItemX.setText(QString::x);
//I want to hide this once I am out of scene.It is a member variable. I tried
//taking local variable but it didn't work.
//Similarly for y and other slots
}