Built with Qt

Developing Superior Avionics Technology with Qt


Tokyo Room October 19, 2016 3:10 pm - 3:35 pm

Bookmark and Share

Jeremiah Pate
Collier Moody

Qt is a constantly evolving API that has embraced many of the new C++ concepts introduced in C++11 and C++14, but the core QObject class still has some surprising limitations. If you want to use Qt’s tried and true signal/slot mechanism, you must derive your classes from QObject, but there are a few subtle snags that you’ll have to avoid, such as: – A class cannot have multiple QObjects in its ancestry – You cannot use virtual inheritance with QObject-based classes – The Q_OBJECT macro cannot be used in templated classes The bad news is that these limitations can trip up modern C++ developers who want to use advanced techniques like templates and multiple inheritance. The good news is that Qt is evolving quickly to suit modern needs, and that there are workarounds that can be used today. This talk will focus on techniques that can work around QObject’s current limitations while Qt is still evolving. We will discuss different patterns that programmers can use to write QObject classes that use advanced templating, while still maintaining the myriad of conveniences provided by the QObject system. We will cover how Qt 5’s new connection syntax can solve some modern problems, and present more intricate solutions for the problems left standing. We’ll also go over some tips and tricks using pure virtual functions that can get around QObject’s multiple inheritance issues, while still steering clear of the “dreaded diamond” problem. Finally, we will cover recent discussions on the Qt development mailing list about how Qt contributors can help evolve Qt to better work with templates out-of-the-box, while noting a few key complications that must be solved.