For simple widget rendering you don't need QApplication::exec(), here is an example:
@#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QPushButton button("test");
button.resize(button.sizeHint());
QImage image(button.rect().size(), QImage::Format_RGB32);
image.fill(0xffffffff);
QPainter p(& image);
button.render(&p);
p.end();
image.save("image.png");
return 0;
}
@
If you do need input event processing etc from Qt as well, you might still be able to do it in a single thread. What you'd do is use glutIdleFunc() to register a function for GLUT to call when the GLUT event loop is idle. Then you'd call QApplication::processEvents() or potentially QApplication::processEvents(QEventLoop::WaitForMoreEvents, 10) or similar to prevent your application from using too much CPU. 10 is the timeout value in ms, which you might want to tweak a bit to keep the application responsive. Alternatively you could use glutTimerFunc() to call QApplication::processEvents() only every so often.
I would avoid using threads if possible, since that is quite error-prone.