[Interest] Requesting QObject::bind() method

Prashanth Udupa prashanth.udupa at gmail.com
Wed Mar 22 08:13:59 CET 2017


Hi Thiago,


> But let me put it this way: will not accept new text-based API for signal,
> slots and properties in QObject. You can do that externally, as you've done
> it, but I won't take it in QtCore.


Ok.


> So we need the compile-time checking. What can we use to identify the
> property
> changing? A read-only property that changes has two C++ identifiers: the
> getter
> and the notify signal. And what can we use to identify the receiving
> property?

I agree, QObject API should ideally have compile time checks rather than
runtime debug dumps or bool isValid()s.

> The getter and the setter.
> So this new functionality would be:
>         QObject::bind(sender, &Sender::signalName, receiver,
> &Receiver::setter);
> This is exactly connect() we already have.
>

True. Makes sense.

Thanks,
Prashanth


On Wed, Mar 22, 2017 at 12:19 PM, Thiago Macieira <thiago.macieira at intel.com
> wrote:

> Em terça-feira, 21 de março de 2017, às 22:58:38 PDT, Thiago Macieira
> escreveu:
> > Em terça-feira, 21 de março de 2017, às 19:38:19 PDT, Prashanth Udupa
> >
> > escreveu:
> > > QSlider *slider = ...
> > > QLabel *label = ....
> > > QObject::bind(slider, "value", label, "text”);
> >
> > This is a bad example because "text" is a string and would require a
> > conversion. But let's say we're connecting a slider to a QProgressBar.
> You
> > can just write:
> >
> > QObject::connect(slider, &QSlider:valueChanged,
> >               &progressBar, &QProgressBar::setValue);
>
> And your other example:
>
> > QSlider *slider = ....
> > QLabel *label = ....
> > QObject::bind(slider, "value", label, "text", [](const QVariant &v) {
> return
> > v.toInt()*2; });
>
> Would be:
>
> QObject::connect(slider, &QSlider::valueChanged, &label, [label](int
> value) {
>                 label->setText(QString::number(value * 2));
>         });
>
> But let me put it this way: will not accept new text-based API for signal,
> slots and properties in QObject. You can do that externally, as you've done
> it, but I won't take it in QtCore.
>
> So we need the compile-time checking. What can we use to identify the
> property
> changing? A read-only property that changes has two C++ identifiers: the
> getter
> and the notify signal. And what can we use to identify the receiving
> property?
> The getter and the setter.
>
> So this new functionality would be:
>
>         QObject::bind(sender, &Sender::signalName, receiver,
> &Receiver::setter);
>
> This is exactly connect() we already have.
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



-- 
Thanks and Warm Regards,
Prashanth N Udupa
URL: http://www.prashanthudupa.com

Scan the QR Code below using KitApp
<https://play.google.com/store/apps/details?id=me.kitapp.kitapp> for
Android & message me on my phone without revealing your phone number!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170322/8d23cb3d/attachment.html>


More information about the Interest mailing list