I'm developing application for Windows. I have an exe and a dll. In dll I try to emit a signal, and in exe I have a slot that should receive it. If I implement the slot method in dll instead of exe, it works just fine.
By searching previous posts I understood that problem lies within exporting dll, but as I tested those solution they didn't fix the problem. From exe I can instantiate an object that is defined in dll, and 'normal' method calls are passed with no problems.
So, what I did is the following:
in a .h file included in dll:
#ifdef DLL_BUILD
# define DLL_EXPORT Q_DECL_EXPORT
#else
# define DLL_EXPORT Q_DECL_IMPORT
#endif
#ifdef DLL_BUILD
# define DLL_EXPORT Q_DECL_EXPORT
#else
# define DLL_EXPORT Q_DECL_IMPORT
#endif
To copy to clipboard, switch view to plain text mode
in dll's .pro file:
DEFINES += DLL_BUILD
DEFINES += DLL_BUILD
To copy to clipboard, switch view to plain text mode
...and finally in dll's class description:
class DLL_EXPORT MyDLL
: public QObject {
Q_OBJECT
...
signals:
void testSignal();
class DLL_EXPORT MyDLL : public QObject
{
Q_OBJECT
...
signals:
void testSignal();
To copy to clipboard, switch view to plain text mode
Is there something that I'm missing? Slots, signals and connections should be OK, at least they work if implemented inside the dll. The only thing that I'm unsure of is that is it OK to use Qt::AutoConnection connection type in connect method?
Bookmarks