I\'m using Qt5.1 and I\'m trying to create a QApplication without a display. I need to draw text with QPainter, so I need to use QApplication (or QGuiApplication), otherwise
Yes, that's a Qt 3 (?) thing that is gone in Qt 5. Try running your application with the -platform offscreen command line option instead.
Note that you don't need QApplication or linking to QtWidgets to just draw upon a QImage, using QGuiApplication (and linking to QtGui) is sufficient.
If you want to create an app without GUI, you need to use QCoreApplication instead of QApplication.