Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Click Event of QLineEdit in Qt?

Tags:

qt

How to get Click Event of QLineEdit in Qt ?

I am not able to see any SLOT related to click in QLineEdit ?

like image 426
Bokambo Avatar asked Jun 23 '11 09:06

Bokambo


1 Answers

I don't think subclassing a QLineEdit is the right choice. Why subclass if you don't need to? You could instead use event filters. Check out QObject::eventFilter.

Example:

MyClass::MyClass() :
    edit(new QLineEdit(this))
{
    edit->installEventFilter(this);
}

bool MyClass::eventFilter(QObject* object, QEvent* event)
{
    if(object == edit && event->type() == QEvent::FocusIn) {
        // bring up your custom edit
        return false; // lets the event continue to the edit
    }
    return false;
}
like image 59
buck Avatar answered Sep 22 '22 13:09

buck