View Full Version : Signals and Slots in dll
ankurjain
24th March 2006, 06:53
hi,
can anybody tell me if i can use signals and slots in dll ??
i wrote a dll. in it there is a function that creates context menu, function that adds action (cut, copy, paste) to it, functions to implement the actions.
i connected the via signals and slots the functions called on clicking the actions.
But i can't see the effect.
please help and clarify.
high_flyer
24th March 2006, 09:35
if you have QObjects in your dll you can use signal slots.
ankurjain
24th March 2006, 09:43
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 ??
niko
24th March 2006, 18:17
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....
ankurjain
29th March 2006, 06:34
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 :
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.
ChristianEhrlicher
29th March 2006, 06:41
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.
#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
ankurjain
29th March 2006, 07:32
thanx for replying christian,
but the same error persists.
i don know why ... is there some error in import/export
my code goes as :
#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 :
fatal error C1017: invalid integer constant expression
i changed
#if QT_CC_MSVC to #ifdef QT_CC_MSVC
it gave same error as earlier ..
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.
ChristianEhrlicher
29th March 2006, 07:57
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
ankurjain
29th March 2006, 08:12
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 ?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.