Re: Signals and Slots in dll
if you have QObjects in your dll you can use signal slots.
Re: Signals and Slots in dll
i have to connect a QAction Object (deleteAct) and QGrid inherited from QTableWidget Object (table).
On click of a context menu item this slot must be executed.
my dll is making a table in the target project.
connect(deleteAct,SIGNAL(triggered()),this,SLOT(de leteRow()))
is this right ??
Re: Signals and Slots in dll
if both classes inherit from QObject and have the Q_OBJECT-macro it should work.
you could probalby first link it directly into the executable - and then try creating the dll....
Re: Signals and Slots in dll
hi,
i hav implemented signals and slots in dll.
now if i am importing the dll in my project, it gives errors and warnings as follows :
Code:
xxx : warning C4273: 'public: static struct QMetaObject const QGrid::staticMetaObject' : inconsistent dll linkage. dllexport assumed.
xxx : error C2491: 'QGrid::staticMetaObject' : definition of dllimport static data member not allowed
xxx : warning C4273: 'metaObject' : inconsistent dll linkage. dllexport assumed.
xxx : warning C4273: 'qt_metacast' : inconsistent dll linkage. dllexport assumed.
xxx : warning C4273: 'qt_metacall' : inconsistent dll linkage. dllexport assumed.
if i remove signals and slots then it compiles fine .... what to do to remove the error.
Re: Signals and Slots in dll
Quote:
Originally Posted by ankurjain
hi,
if i remove signals and slots then it compiles fine .... what to do to remove the error.
Define your DLL_EXPORT - macro in the correct way.
Code:
#ifdef MAKE_YOUR_DLL
# define YOUR_DLL_EXPORT Q_DECL_EXPORT
#else
# if Q_CC_MSVC
# define YOUR_DLL_EXPORT Q_DECL_IMPORT
# else
# define YOUR_DLL_EXPORT
# endif
#endif
Re: Signals and Slots in dll
thanx for replying christian,
but the same error persists.
i don know why ... is there some error in import/export
my code goes as :
Code:
#ifdef Q_OS_WIN
#ifdef BUILD_QGRID
# define QGRID_EXPORT Q_DECL_EXPORT
#else
# define QGRID_EXPORT Q_DECL_IMPORT
#endif
# else
# define QGRID_EXPORT
# endif
i tried ur code ... i gives error :
Code:
fatal error C1017: invalid integer constant expression
i changed
#if QT_CC_MSVC to #ifdef QT_CC_MSVC
it gave same error as earlier ..
Code:
xxx : warning C4273: 'public: static struct QMetaObject const QGrid::staticMetaObject' : inconsistent dll linkage. dllexport assumed.
xxx : error C2491: 'QGrid::staticMetaObject' : definition of dllimport static data member not allowed
xxx : warning C4273: 'metaObject' : inconsistent dll linkage. dllexport assumed.
xxx : warning C4273: 'qt_metacast' : inconsistent dll linkage. dllexport assumed.
xxx : warning C4273: 'qt_metacall' : inconsistent dll linkage. dllexport assumed.
Re: Signals and Slots in dll
It is Q_CC_MSVC and not QT_CC_MSVC
You maybe have not set BUILD_QGRID when building your dll (as the error states you're using dllimport == Q_DECL_IMPORT).
Please read about importing / exporting symbols in your favorite msvc book / at msdn.mcrosoft.com
Re: Signals and Slots in dll
Sorry my mistake (Q and QT misspell),
i defined BUILD_QGRID in .pro file as DEFINES += BUILD_QGRID
also it shows in the project settings as /D "BUILD_QGRID"
the problem is due to the Q_OBJECT directive.
if i comment the line and the slots in the class it works fine.
also the error is stating "definition of dllimport static data member not allowed"
and warnings regarding exporting. i didn't got these errors.
is there some other way to define the BUILD_QGRID, like in the cpp file ?