magland
29th October 2011, 14:08
If I do:
int main(int argc, char *argv[])
{
QCoreApplication app(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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;
....
}
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);
QCoreApplication app2(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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!
int main(int argc, char *argv[])
{
QCoreApplication app(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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;
....
}
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);
QCoreApplication app2(argc,argv);
qDebug() << "qApp=" << qApp;
....
}
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!