Qt/MFC Migration Framework - How to support reloading of DLL?
I'm using the Qt 4.7.1 and Qt/MFC Migration Framework. I'm building a DLL that has a Qt GUI and will be used as plugin in a MFC application.
I'm following the directions at http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-walkthrough.html. I can load the app in the MFC application and my Qt gui is displayed. However, when I unload the DLL from within the MFC app and then try to reload the DLL I get an error about:
ASSERT failure in QWidget: "Widgets must be created in the GUI thread."
How can I make it so my DLL can be loaded and unloaded and reloaded without error?
I think GUI must be created in main thread, reloaded GUI is not on main thread.
I believe you are correct. I think the MFC application kicks off a new thread each time the plugin is loaded (but does not unload the DLL). Therefore, the QApplication created when the DLL first starts up is still around, but the reloaded plugin is executing on a new thread and can't access it.
Did you get anywhere with this? I've just started looking at the Qt/MFC Migration Framework and have the same issue.
I think I did eventually overcome this particular hurdle only to encounter several others. I think I did this by making sure to call qApp->quit(); and delete qApp when my plugin was unloaded.
However for my case, I felt like I was climbing uphill trying to use Qt and there is very little information on Qt/MFC on the net. In the end I bit the bullet and decided to develop in MFC which I don't think is that much worse than Qt.