If I do:

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QCoreApplication app(argc,argv);
  4. qDebug() << "qApp=" << qApp;
  5. ....
  6. }
To copy to clipboard, switch view to plain text mode 

The of course qApp is not null. But if define MyCoreApplication in a shared library (dll on windows), and I do


Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. MyCoreApplication app(argc,argv);
  4. qDebug() << "qApp=" << qApp;
  5. ....
  6. }
To copy to clipboard, switch view to plain text mode 

Then qApp is NULL! That is not what I would expect. The problem is that I have qApp->applicationDirPath() calls all over the place, and (qApp->setProperty()), so I can't affort to not have access to qApp in the main app and in the shared lib.

If I do this hack...

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. MyCoreApplication app(argc,argv);
  4. QCoreApplication app2(argc,argv);
  5. qDebug() << "qApp=" << qApp;
  6. ....
  7. }
To copy to clipboard, switch view to plain text mode 

Then it works... however, I suspect I now have two versions of qApp, which is okay for qApp->applicationDirPath(), but not good for setProperty() on qApp.

So, is this the expected behavior (even for a shared (non-static) link to a dll)? If so, then what's a good work around.

Thanks!