[Qt-jambi-interest] Focus on Qlineedit?
Eskil Abrahamsen Blomfeldt
eblomfel at trolltech.com
Tue Jul 15 08:46:16 CEST 2008
Luis Zaldivar wrote:
> How do I detect when a QLineEdit gets focus?
> Seems like there is not focus signal for QLineEdit. It seems like it can
> be emulated with eventfilter() and hasfocus() but is there an easier way?
> Sorry if it is a dumb question :)
>
Hi, Luis.
QApplication has a signal called "focusChanged" which is emitted when
the focus changes. It emits two arguments, the first being the widget
losing focus and the second the one gaining focus. Either or both of
these may be null. In order to connect to this signal, do something like
the following:
QApplication.instance().focusChanged.connect(myReceiver,
"mySlot(QWidget, QWidget)");
You can also get this information from inside the widget, if you
subclass it and override the focusInEvent() and focusOutEvent() methods.
-- Eskil
More information about the Qt-jambi-interest
mailing list