[Interest] Finish QLineEdit editing when user clicks anywhere outside the QLineEdit

Murphy, Sean smurphy at walbro.com
Tue Aug 13 21:55:44 CEST 2019


> Hi, had a similar problem, couldn't find any other solution than using an
> event filter, but it turned out being not so bad, made a small class:
> 
> In my MainWindow I have an instance of that class, and in MainWindows's
> ctor I initialize it:
> 
> MouseFilter mf;
> ...
> mf.setWidget(ui->lineEdit);
> qApp->installEventFilter(&mf);

Thank you. I was going down this path as well, that I might have to do it as an 
event filter installed somewhere up the hierarchy, instead of just being able 
to do it within a custom class that inherits from QLineEdit. So far I haven't 
found a way to do that.

And you're right, it's not so bad to do it via an event filter, but it's just one 
extra step I have to remember to do, every time I want to re-use this 
custom line edit, either within this application, or in other applications.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com


More information about the Interest mailing list