Image manipulation in Qt console app segfaults?
-
Hi all,
Can someone tell me why the following creates a segfault?
It does so at the drawText line.@
int main(int argc, char *argv[])
{
QApplication app(argc, argv, QApplication::Tty);QImage img(800, 800, QImage::Format_RGB16); QPainter painter(&img); QFont font("utsaah", 50, QFont::Bold, true); painter.setPen(QPen(Qt::white)); painter.setFont(font); painter.drawText(0,0, 200,200, Qt::AlignLeft, "blah"); return 0;}
@Is there any way i can make this work without it needing to become a Qt GUI app?
Thanks in advance.
-
Hi,
what do you mean by "... become a Qt GUI app" or a "... Qt console app"? When you create Qt Console project with the QtCreator your pro-file has a
@QT -= gui@
in which case the code given does not compile, because QApplication, QPainter and QImage are not available.
So, do you want to avoid creating a QWidget of any kind? That should be no problem. In fact, when commenting the above line
@#QT -= gui@
I can compile your code and execute it without any problems.
Best Soraltan