More C++ functional APIs in Qt

118 views
Skip to first unread message

Thomas Zander

unread,
Nov 19, 2012, 8:44:06 AM11/19/12
to functional-pro...@googlegroups.com
Hi all,

I was at the Stockholm meeting last week where Staffan Eketorp gave a wonderful introduction to functional programming using C++ features.
At this talk we concluded that the new <future> feature in C++11, is a bit too simple to use directly, its missing a runtime component to do things like thread-group management, and Staffan mentioned he'd have liked to see callbacks.


I have been working a bit with a framework in C++ that is pretty interesting for functional programming fans and in my opinion more mature and its called "Qt Concurrent".
It solves most of the issues that Staffan mentioned in his talk, and it does so quite elegantly.

So if people are interested in doing functional and/or concurrent programming I highly recommend Qt Concurrent.
See more info;
http://qt-project.org/doc/qt-4.8/threads-qtconcurrent.html

Notice that when the docs mention "signals and slots" this is the callback mechanism that Qt has.
You essentially define a method on your class to be a 'slot' and then any signal[1] can be connected to it with a simple statement.
Look at it as a mix between function pointers, callbacks and the listener pattern.

Full disclosure; I was working at Trolltech when the concurrent framework was build, I was not actually involved in its architecture, but I can't claim to be unbiased.

1) for an example of signals;
 http://qt-project.org/doc/qt-4.8/qfuturewatcher.html#signals

--
Thomas Zander
Reply all
Reply to author
Forward
0 new messages