deepal_de
9th June 2011, 05:39
hello
How can i catch a QlineEdit focusIn event from the main window..
without subclassing QlineEdit ...
Santosh Reddy
9th June 2011, 06:44
You can create and install an event filter, and emit a signal in there, something like this
class FocusInSignal: public QObject
{
Q_OBJECT
...
signals:
void focusIn(void);
protected:
bool FocusInSignal::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::FocusIn) {
emit focusIn();
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
}
// in the main window
FocusInSignal* filter = new filter(this);
connect(filter, SIGNAL(focusIn()), this, SLOT(lineEditGotFucus()));
lineEdit->installFilter(filter);
void MainWindow::lineEditGotFucus(void)
{
// processes
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.