[Interest] Problem about signals/slots in Qt 5
Josiah Bryan
josiahbryan at gmail.com
Tue Sep 18 14:30:49 CEST 2012
On Tue, Sep 18, 2012 at 8:21 AM, Stephen Chu <stephen at ju-ju.com> wrote:
> On 9/18/12 4:10 AM, Thiago Macieira wrote:
> >> How could I solve this?
> >>
> >> In Qt 4 I could specialize the signal using SIGNAL(valueChanged(int)),
> how
> >> could I do in Qt 5?
> >
> > void (QSpinBox:: *signal)(int) = &QSpinBox::valueChanged;
> > QObject::connect(spinBox, signal, slider, &QSlider::setValue);
>
>
> or:
>
> QObject::connect(spinBox, (void (QSpinBox:: *)(int))
> &QSpinBox::valueChanged, slider, &QSlider::setValue);
>
> if you want to keep it in one line.
>
> I like this new syntax much better since it finds signal/slot mismatches
> at compile time. I used to miss the connection mismatch messages in the
> sea of my REALLY chatty logs. And pulling my hairs wondering why
> something doesn't work. :)
I agree! I can't tell you how many times I've checked and rechecked my
code, only to find out it was a sig/slot mismatch all along. Crikey! :-)
--
Josiah Bryan
765-215-0511
josiahbryan at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120918/f363b562/attachment.html>
More information about the Interest
mailing list