[Interest] Finish QLineEdit editing when user clicks anywhere outside the QLineEdit
Henry Skoglund
henry at tungware.se
Tue Aug 13 22:06:38 CEST 2019
Hmm, about that extra step, to remember the filter stuff, since you
already have a custom line edit class, why not embed the MouseFilter
class inside it?
I mean, the filter does not have to reside in MainWindow, it needs only
the qApp pointer, so you could wire it up in your custom line edit's
ctor instead. Thus making it an integrated part of your custom class :-)
On 2019-08-13 21:55, Murphy, Sean wrote:
>> 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
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list