Results 1 to 9 of 9

Thread: Signals and Slots in dll

  1. #1
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Signals and Slots in dll

    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.
    Do what u r afraid to do, and the death of fear is sure.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Signals and Slots in dll

    if you have QObjects in your dll you can use signal slots.

  3. #3
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question 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 ??
    Do what u r afraid to do, and the death of fear is sure.

  4. #4
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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....

  5. #5
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 :

    Qt Code:
    1. xxx : warning C4273: 'public: static struct QMetaObject const QGrid::staticMetaObject' : inconsistent dll linkage. dllexport assumed.
    2. xxx : error C2491: 'QGrid::staticMetaObject' : definition of dllimport static data member not allowed
    3. xxx : warning C4273: 'metaObject' : inconsistent dll linkage. dllexport assumed.
    4. xxx : warning C4273: 'qt_metacast' : inconsistent dll linkage. dllexport assumed.
    5. xxx : warning C4273: 'qt_metacall' : inconsistent dll linkage. dllexport assumed.
    To copy to clipboard, switch view to plain text mode 

    if i remove signals and slots then it compiles fine .... what to do to remove the error.
    Do what u r afraid to do, and the death of fear is sure.

  6. #6
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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.
    Qt Code:
    1. #ifdef MAKE_YOUR_DLL
    2. # define YOUR_DLL_EXPORT Q_DECL_EXPORT
    3. #else
    4. # if Q_CC_MSVC
    5. # define YOUR_DLL_EXPORT Q_DECL_IMPORT
    6. # else
    7. # define YOUR_DLL_EXPORT
    8. # endif
    9. #endif
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 :

    Qt Code:
    1. #ifdef Q_OS_WIN
    2. #ifdef BUILD_QGRID
    3. # define QGRID_EXPORT Q_DECL_EXPORT
    4. #else
    5. # define QGRID_EXPORT Q_DECL_IMPORT
    6. #endif
    7. # else
    8. # define QGRID_EXPORT
    9. # endif
    To copy to clipboard, switch view to plain text mode 

    i tried ur code ... i gives error :

    Qt Code:
    1. fatal error C1017: invalid integer constant expression
    To copy to clipboard, switch view to plain text mode 

    i changed
    #if QT_CC_MSVC to #ifdef QT_CC_MSVC

    it gave same error as earlier ..

    Qt Code:
    1. xxx : warning C4273: 'public: static struct QMetaObject const QGrid::staticMetaObject' : inconsistent dll linkage. dllexport assumed.
    2. xxx : error C2491: 'QGrid::staticMetaObject' : definition of dllimport static data member not allowed
    3. xxx : warning C4273: 'metaObject' : inconsistent dll linkage. dllexport assumed.
    4. xxx : warning C4273: 'qt_metacast' : inconsistent dll linkage. dllexport assumed.
    5. xxx : warning C4273: 'qt_metacall' : inconsistent dll linkage. dllexport assumed.
    To copy to clipboard, switch view to plain text mode 
    Do what u r afraid to do, and the death of fear is sure.

  8. #8
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  9. #9
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 ?
    Do what u r afraid to do, and the death of fear is sure.

Similar Threads

  1. Signals and Slots Problem
    By GenericProdigy in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2009, 09:06
  2. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 10:31
  3. Problem with SpinBox signals and slots
    By ramstormrage in forum Newbie
    Replies: 4
    Last Post: 2nd May 2008, 01:45
  4. signals and slots in plugins
    By anderl in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 13:57
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.