C++ (Qt)
void cLayoutText::focusOutEvent(QFocusEvent *event)
{
setTextInteractionFlags(Qt::NoTextInteraction);
QTextCursor cursor = textCursor();
cursor.clearSelection();
setTextCursor(cursor);
emit lostFocus(this);
QGraphicsTextItem::focusOutEvent(event);
}