Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Draw text in an image without a QApplication
daviddoria last edited by
To draw text in an image, I usually use a QPainter. This method requires that a QApplication be available. However, I am trying to write this function in a library so that it can be called from a Qt program or from a non Qt program (just using some bits of Qt as library functions, rather than necessarily using it for a GUI).
Is there a way to do something like this:
int main(int argc, char *argv)
QApplication app(argc, argv);
QPixmap pixmap(20, 20);
QFont font("", 6); // arbitrary (default) font, size 2
painter.drawText(QPointF(10,10), "test"); // bottom left corner of the text seems to start at this point
but without a QApplication?
AcerExtensa last edited by
You can try to instantiate QApplication instance in the thread in your dll and do the work there, maybe it will work.(works for QNAM for example). But in general it is not allowed and unsupported.