With Qt 5 and 6 I have had to also add QtWidgets/ to the #include <> to access QApplication.
#include <QtWidgets/QApplication>
Also mentioned here.