If I do:
int main(int argc, char *argv[])
{
qDebug() << "qApp=" << qApp;
....
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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
int main(int argc, char *argv[])
{
MyCoreApplication app(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
int main(int argc, char *argv[])
{
MyCoreApplication app(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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...
int main(int argc, char *argv[])
{
MyCoreApplication app(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
int main(int argc, char *argv[])
{
MyCoreApplication app(argc,argv);
QCoreApplication app2(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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!
Bookmarks