QGraphicsTextItem always gets focus once clicked
I have a QGraphicsView containing a custom QGraphicsTextItem. The QGraphicsTextItem has a double-click event:
Code:
{
MGlobal
::displayInfo(MQtUtil
::toMString(QString().
sprintf("Double click on textId")));
}
What goes well:
When I double click in the QGraphicsView but not in the QGraphicsTextItem, then nothing happens, which is normal. When I double click directly on the QGraphicsTextItem, then I get a "Double click on textId" message, as expected.
What goes wrong:
However when I then double click again wherever on my main QGraphicsView but not in the QGraphicsTextItem, then I always get the above message.
Question:
How come the QGraphicsTextItem keeps getting the mouseDoubleClickEvent events even if I am not directly clicking on it ?
My QGraphicsTextItem is created this way from the QGraphicsView constructor:
Code:
oneTextNode=new myQGraphicsTextItemClass();
scene()->addItem(oneTextNode);
and my QGraphicsTextItem class looks like:
Code:
{
Q_OBJECT
public:
virtual ~myQGraphicsTextItemClass() {};
protected:
};
and its constructor:
Code:
{
setPlainText("Hello");
setTextInteractionFlags(Qt::TextEditorInteraction);
}
Thanks.
Re: QGraphicsTextItem always gets focus once clicked
Please provide a minimal compilable example reproducing the problem.