[Interest] How to display custom data entry form on QLineEdit click ?
Andy
asmaloney at gmail.com
Mon Feb 1 18:18:21 CET 2016
Edward:
"Is the “[=]()” a place holder?"
He's using C++11 lambdas. There are a couple of good explanations here:
https://stackoverflow.com/questions/7627098/what-is-a-lambda-expression-in-c11
---
Andy Maloney // https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>
On Mon, Feb 1, 2016 at 12:12 PM, Edward Sutton <edward.sutton at subsite.com>
wrote:
> Hi Prashanth,
>
> I do not understand how the connect syntax example or how the signal
> *filteredEvent* is raised?
>
> Could you please elaborate on implementation of the connect?
>
> On Feb 1, 2016, at 10:28 AM, Prashanth Udupa <prashanth.udupa at gmail.com>
> wrote:
>
> Create a Event2Signal class as follows.
>
> #include <QMap>
> #include <QList>
> #include <QEvent>
> #include <QObject>
>
> class Event2Signal : public QObject
> {
> Q_OBJECT
>
> public:
> Event2Signal(QObject *parent=0) : QObject(parent) { }
> ~Event2Signal() { }
>
> void filterEvent(QObject *o, QEvent::Type type) {
> if(!o) return;
> if( m_objectEventsMap.contains(o) ) {
> QList<QEvent::Type> &events = m_objectEventsMap[o];
> if(events.contains(type))
> return;
> events.append(type);
> } else {
> m_objectEventsMap[o].append(type);
> o->installEventFilter(this);
> }
> }
>
> signals:
> void filteredEvent(QObject *o, QEvent *e, bool *filtered);
>
> protected:
> bool eventFilter(QObject *obj, QEvent *e) {
> bool filtered = false;
> emit filteredEvent(obj, e, &filtered);
> return filtered;
> }
>
> private:
> QMap<QObject *, QList<QEvent::Type> > m_objectEventsMap;
> };
>
> Now, lets say you want to take some action when user mouse-presses on a
> lineEdit. You can do this
>
> Event2Signal *e2s = new Event2Signal(lineEdit);
> e2s->filterEvent(lineEdit, QEvent::MouseButtonPress);
> connect(e2s, &Event2Signal::filteredEvent, [=]() {
> // Activate your form and do other things here..
> });
>
>
> I do not understand how the connect syntax example or how the signal
> *filteredEvent* is raised?
>
> Is the “[=]()” a place holder?
>
> If I had:
>
> FormInputData::FormInputData(QWidget *parent) :
>
> QDialog(parent)
>
> ,ui(new Ui::FormSoftwareUpdateCheck)
>
> {
>
> ui->setupUi(this);
>
>
> // What does the connect code look like ?
> connect(e2s, &Event2Signal::filteredEvent,
> this, SLOT(mouseButtonPressHandler)));
> }
>
>
> void FormInputData::mouseButtonPressHandler()
> {
> // Show custom calculator entry form
> }
>
> Thanks,
>
> -Ed
>
>
>
> You can reuse this method for handling other kinds of events in
> signal-slot style.
>
> Hope this helps.
>
> / Prashanth
>
> On Mon, 1 Feb 2016 at 21:41 Edward Sutton <edward.sutton at subsite.com>
> wrote:
>
>> I want to display a form with a numeric touch key pad plus a decimal
>> point when user clicks on a QLIneEdit field.
>>
>> I did not see any signal such as editingStarted.
>>
>> What are approaches to implementing a custom data entry?
>>
>> I am targeting Android and iOS with a QWidget app.
>>
>> -Ed
>>
>
>>
> This email and any files transmitted with it from The Charles Machine
> Works, Inc. are confidential and intended solely for the use of the
> individual or entity to which they are addressed. If you have received this
> email in error please notify the sender. Our company accepts no liability
> for the contents of this email, or for the consequences of any actions
> taken on the basis of the information provided, unless that information is
> subsequently confirmed in writing. Please note that any views or opinions
> presented in this email are solely those of the author and do not
> necessarily represent those of the company. Finally, the recipient should
> check this email and any attachments for the presence of viruses. The
> company accepts no liability for any damage caused by any virus transmitted
> by this email.
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160201/b378078b/attachment.html>
More information about the Interest
mailing list