Your way to access a function in the dll is wrong (this just works for c-functions but it isn't needed at all). Test.h is nearly correct. But you shouldn't use __declspec(dllexport) but Q_DECL_EXPORT / Q_DECL_IMPORT to be platform independent - there is no need to mask this with Q_OS_WIN (in fact this is wrong since mingw don't know anything about __declspec() and will not compile your code)
#ifdef BUILD_QGRID
# define QGRID_EXPORT Q_DECL_EXPORT
#else
# define QGRID_EXPORT Q_DECL_IMPORT
#endif
#ifdef BUILD_QGRID
# define QGRID_EXPORT Q_DECL_EXPORT
#else
# define QGRID_EXPORT Q_DECL_IMPORT
#endif
To copy to clipboard, switch view to plain text mode
Your test.cpp is wrong. There is no need for CreateQgrid(QWidget *parent) because you exported the class and can access QGrid directly. Also 'extern "C"' is not needed.
In your main project you only have to include test.h and access QGrid like normal. When linking you have to link against the import lib (test.lib) created by the linker during test.dll creation
Bookmarks