Solved qInstallMessageHandler vs. QApplication: order of creation
-
In the Qt documentation of
qInstallMessageHandler
, there is a little example given where this is called BEFORE the application object is created:int main(int argc, char **argv) { qInstallMessageHandler(myMessageOutput); QApplication app(argc, argv); ... return app.exec(); }
Is this the required or recommended order? The rest of the documentation doesn't seem to offer an explanation. For almost everything else, it always seems to be necessary to create the application first.
I suppose that the constructor of
app
might issue warnings, but that is highly unlikely. -
@Robert-Hairgrove
I don't think it matters. I certainly have doneqInstallMessageHandler()
not as the first statement in my program, rather much later well afterQApplication app(argc, argv)
. -
@JonB Thanks!