On terça-feira, 18 de setembro de 2012 18.40.28, Stephen Chu wrote: > On 9/18/12 8:30 AM, Josiah Bryan wrote: > > 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! :-) > > The only problem I have with the new syntax is it doesn't handle the > case when the slot require more arguments than the signal but the extra > arguments in the slot are all default arguments. > > For example, I can't connect my signal showMessage(QString) to > QStatusBar::showMessage(QString, int=0) this way. I'll get a static > assert "The slot requires more arguments than the signal provides."
The C++ language doesn't allow that. Default arguments only show up when you're calling a function directly. The moment that you take the address and put it in a function pointer, they aren't visible anymore. To complete that connection, you need a lambda: QObject::connect(sender, &MyClass::showMessage, [=](const QString &s) { statusBar->showMessage(s); }); -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center Intel Sweden AB - Registration Number: 556189-6027 Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest