[Solved]QApplication static linkage and plugins
I build a Main App/plugin application using qt 5.1 for multi platform purpose.
In windows, the Main app is statically linked whereas the plugins are dynamically linked (the first one is a requirement, the second more of a choice :) )
Up until now, everything worked fine.
Now I want the plugin to be able to show some stuff (mostly configuration...) and everything is not working fine on windows. When I intend to show something i got a "QWidget: Must construct a QApplication before a QPaintDevice". after a little bit of research, i understand that everything relying on a UI must have a instance of QApplication running, so qApp should not be NULL, but it is with my plugins but not my main app.
Anyone knows how to set/assign a QApplication ?
thanks in advance :)
basically you have nothing to do other than creating an QApplication instance.
But to get you right:
Your main app is linked statically against all Qt libs. Only your plugin is loaded dynamically? And this plugin also uses Qt stuff?
thanks for your reply,
if it is possible I prefer to not create a QApplication, but rather use the one from my main application if possible...
But yes only my plugins are loaded dynamically and yes they use non-ui Qt stuff
[quote author="jpalbertini" date="1383577128"]
But yes only my plugins are loaded dynamically and yes they use non-ui Qt stuff[/quote]
So how do you link your plugin binary against Qt?
And what does your plugin do exactly? Doesn't sound like it's non-ui stuff when a QPaintDevice is required...
my plugins are dynamically linked against qt
basically i got two plugin, one which sends arrays of data, the other one sends QImages
so this means your application runs with 2 different Qt binaries...
You should have created a QApplication in your main app, right?
I still don't know where you are missing the QPaintDevice...
But nvertheless you shouldn't mix statically and dynamic linked binaries. Either way link all dynamically or statically. I would suggest you also link your "plugins statically":http://qt-project.org/doc/qt-4.8/plugins-howto.html#static-plugins.
one thing I also forgot to mention is that I have another app, which is dynamically linked against Qt that work fine and plugins can send QImages directly without a problem.
So my thoughts are that the QCoreApplication::self value is not pass correctly to the plugin with a statically linked app (the qApp macro is NULL)
sure it is, when you link your plugin against the dynamically linked version of Qt wherein the QApplication object never gets initialized.
Is there a way that I assign it myself ? the self and init() are marked as private so my range of action is kinda limited, without having to rebuilding Qt with some sort of a setInstance method...
no ... and don't do it!
You do want to assign a object from a statically linked address space into a dynamically linked one...
Doing this you will probably run into another problem sooner or later.
And also that your application needs 2 Qt distributions doesn't make sense don't you think?
Link your plugins also statically and you should be fine.
ok thanks i'll do that