I have a number of QGraphicsTextItem
and QGraphicsItem
painted inside a QGraphicsView
. This QGraphicsView
has been added to the main Qwidget
.
I have written the "FocusOutEvent
" for this QGraphicsTextItem
and the focus is getting removed only when the "MousePressEvent
" is called within the QGraphicsView
.
Now my concern here is, How to remove the focus of this QGraphicsTextItem
when the MousePressEvent
is called Outside the QGraphicsView
?
In my MainWindow.cpp, I wrote a mousePressEvent
function :
void EyGuiMainWindow::mousePressEvent(QMouseEvent *e)
{
QWidget *w = QApplication::focusWidget();
if(w)
w->clearFocus();
}
But this is not clearing the QGraphicsTextItem
.
Expecting a positive response.