[Development] C++11 for Examples

Matthew Woehlke mw_triad at users.sourceforge.net
Tue Mar 3 22:15:59 CET 2015

On 2015-03-03 14:43, Thiago Macieira wrote:
> On Tuesday 03 March 2015 12:57:55 Matthew Woehlke wrote:
>> On 2015-03-03 05:17, Koehne Kai wrote:
>>> What's missing from the list IMO is using QObject::connect with
>>> PointerToMemberFunction instead of SIGNAL(), SLOT().
>> I thought that was just new in Qt5, and that it does *not* require
>> C++11. The documentation seems to imply so, anyway:
>>   "The number of arguments in the signal or slot are limited to 6 if the
>> compiler does not support C++11 variadic templates."
> The syntax is possible in C++98, but the greatest improvement of the syntax is 
> the ability to connect to lambdas.

True :-). (We might have a QFunction at some point, but I agree that
true lambdas are the most useful case.) Although even without true
lambdas, I think the new signatures allow you to implement "pure"
private slots (that is, call a method on a class's Private without
leaking anything at all into the public interface)?

> There's also the problem you mentioned of the limit of parameters. I would 
> rather people not have to remember how many they can use, so we should 
> restrict this to C++11.
>> ...which brings up another potentially missing item; variadic templates.
>> Not sure if any examples would benefit from those or not...
> Unlikely, we don't create new template classes in our examples. There are also 
> very few classes in the Qt sources that would benefit from it.

I can think of a few that *might*... QString::arg,
QMetaObject::invokeMethod... anything that takes a pseudo-variadic list
(there are a few places), maybe. (Although I can imagine that the
internals may not in all cases be conducive to being rewritten as true

And on a different note... what about initializer lists? I literally
just today was writing:

  QProcess process;
  process.start("cmd", {"arg", "arg", QString::number(value) ...});

I'm not going to start a war on omission of class types (although I do
find it can be quite convenient, especially for things where the type is
obvious, e.g. lots of places that take a QRect, QPoint, QSize, etc.),
but I could see making use of the ability to pass vectors in-place via


More information about the Development mailing list