Get a notification/event/signal when a Qt widget gets focus

You can add en event filter.
This is an example of an application written with QtCreator. This form has a QComboBox named combobox.


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->comboBox->installEventFilter(this);
    .
    .
    .
}

bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
    if (event->type() == QEvent::FocusOut)
    {
        if (object == ui->comboBox)
        {
            qWarning(object->objectName().toLatin1().data());
        }
    }
    return false;
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)