No cursor in QLineEdit after QEvent::FocusIn SOLVED

  • hi all,

    I try to clear a QLineEdit, when it gets the focus. For that I installed an eventFIlter. Basically it works, as it should do, but additional to that there is NO cursor though the QLineEdit has the focus and is editable! This is very irritating...

    Here is my code:

    First the installation of the filter in the constructor of class mainWindow:

    and then the corresponding function:
    @bool MainWindow::eventFilter(QObject *target, QEvent *event)
    if(target == ui->lineEditFilter && event->type() == QEvent::FocusIn)
    return true;
    return false;

    Can anybody help me?

    Thanks in advance,


    Qt 5.2 on Linux Debian Wheezy
    i7 Quadcore
    8 GB RAM
    Nvidia Geforce GTX 285M

  • Qt Champions 2017

    It works as expected i.e cursor is indeed shown. I just tried with QWidget instead of mainwindow. Just see whether someother widget is consuming the focusevent in your program.

  • thx!

Log in to reply