Registering a custom QTextCodec from a staticlib
The title pretty much says it all. I want to be able to instantiate a QTextCodec from my static lib (globally, I guess) such that when I call QTextCodec::codecForName or QTextCodec::codecForMib from the application, the codec has already been registered - without the application knowing or needing to do it itself.
I tried adding a global to the static lib. Either: QMyCodec g_mycodec; or QMyCodec * g_mycodec = new QMyCodec; but it doesn't actually get constructed unless my application references it some how; and at that point, I might as well have just constructed one outright from my _main() function.
Well AFAIK QTextCodec has no Qt-Plugin support (e.g. like the imageformats are). So they are not automatically loaded for you by Qt if they are needed.
You have to register them manually.
I'm not talking about Qt-Plugins. My question could apply to any class instance which needs to be initialized in the global scope of a static lib.