Atomic variables

Qt offers two atomic variable types, namely QAtomicInteger<T> and QAtomicPointer<T>. These variables implement operations like test and set (also known as CAS, the acronym for "compare and swap"), fetch and store, or fetch and add for different memory orderings. For starters, we will only use the ordered memory ordering semantic. Look in the Further reading section for resources on the C++11 memory model.

Starting with Qt 5.7, Qt's atomics actually use the C++11 atomics under the hood, except for platforms or compilers, which don't implement them properly. Their API is more restricted than the C++ API, so for more advanced use cases you should probably employ their Standard Template Library (STL) counterparts.