[Interest] How to display custom data entry form on QLineEdit click ?
Prashanth Udupa
prashanth.udupa at gmail.com
Mon Feb 1 18:22:48 CET 2016
Hi Ed,
> Is the “[=]()” a place holder?
>
>
With Qt 5, you can now use functors and lambda functions for slots:
http://doc.qt.io/qt-5/qobject.html#connect-4.
If you are using a recent compiler which support C++11 standard, then you
should be able to use lambda functions.
Event2Signal *e2s = new Event2Signal(lineEdit);
e2s->filterEvent(lineEdit, QEvent::MouseButtonPress);
connect(e2s, &Event2Signal::filteredEvent,
[=](QObject *o, QEvent *e, bool *filtered) {
// Activate your form and do other things here..
});
Lambda functions have look like this [...](....) { .... }.
- The square brackets allow you to capture one or more (or all)
variables in the current stack. Typically we see usage of =. So when we use
[=], we are saying that within the lambda function we would like to be able
to access all variables accessible from the current stack. You could
specify a list of variables also for example.
- Within the round brackets, you will need to declare all parameters in
the signal function.
- Within the curly braces, you can write your slot code.
You can read up the StackOverflow question that Andy has posted for more
information about this.
Connecting to signals this way frees you from having to write slots in
QObject subclasses all the time.
Best Regards,
Prashanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160201/5feb9641/attachment.html>
More information about the Interest
mailing list