Search code examples
c++qtfocusqtextedit

focusInEvent not called in QLineEdit subclass


I have a Qt/cpp code and display a subclassed QLineEdit. When double-clicking the QLineEdit, the focusInEvent is never called (launched in Maya).

void myQLineEditClass::focusInEvent(QFocusEvent *e)
{
    MGlobal::displayInfo(MQtUtil::toMString(QString().sprintf("HERE")));
    QLineEdit::focusInEvent(e);
}

HERE is never displayed, event if the focusInEvent is present in the .h protect part. Any idea how to get focusInEvents ?


Solution

  • The issue was linked to the fact that the QLineEdit was in a QGraphicsView that was in another QGraphicsView. Bringing the QLineEdit to the higher-level QGraphicsView made it work.