[SOLVED]QVariant passed in SIGNAL LNK 2019 Unresolved External Symbol

  • Still really new to QT development

    Not entirely sure why I am seeing the linker error:

    debug\myproject.exe : fatal error LNK1120: 1 unresolved externals
    jom: C:\Qt\build-myproject-Desktop_Qt_5_2_1_MSVC2012_OpenGL_64bit-Debug\Makefile.Debug [debug\myproject.exe] Error 1120
    jom: C:\Qt\build-myproject-Desktop_Qt_5_2_1_MSVC2012_OpenGL_64bit-Debug\Makefile [debug] Error 2
    10:55:42: The process "C:\Qt\Qt5.2.1\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project myproject(kit: Desktop Qt 5.2.1 MSVC2012 OpenGL 64bit)
    When executing step 'Make'
    10:55:42: Elapsed time: 00:04.

    Here's what I did...

    Here's some code:

    void configValueChanged(QVariant val);


    public slots:
    void configValueChangeHandler(QVariant val);@

    I added @#include <QVariant>@ to both classes and tried to build. That's when I saw the error. Using QT Creator 5.2.1 on Windows 7.

    I also noticed that if I move the method from the public slots: to be just a public regular method, I can compile just fine. But I am hoping to be able to use SIGNALS to pass data around so I can avoid coupling.

    Can QVariant not be used as a signal argument??

    Thank you for any guidance.

  • Lifetime Qt Champion


    Sure they can, did you implement configValueChangeHandler ?

    If so, you would need to post what exact symbols are missing

  • I did:

    @void configValueChangedHandler(QVariant val){

    How do I see what exact symbols are missing. Those two messages are all Im getting in the compile and issues windows:

    moc_myclass.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl MyClass::configValueChangedHandler(class QVariant)" (?configValueChangedHandler@MyClass@@QEAAXVQVariant@@@Z) referenced in function "private: static void __cdecl MyClass::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@MyClass@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)

    When I try to make the implementation public (like the slot accessor), I get a different error... so this :
    @public void configValueChangedHandler(QVariant val){
    doesnt work.

    Ive been away from c++ for about a decade (please forgive my ignorance).

  • Lifetime Qt Champion

    Are you missing the Q_OBJECT macro in your class ? Does it properly inherit from QObject ?

    If the macro is missing, don't forget to re-run qmake before compiling

  • nope... its there

  • Q_OBJECT is intact. Ive run clean, qmake and build. Is there something perhaps I have to reference like a kit or something? The only current kit I have is Desktop Qt 5.2.1 MSVC2012 OpenGL 64bit

  • well, im a complete idiot... I figured it out. it wasnt the QVariant at all. I didnt prepend my classname before my method. Not used to having to do that. Its working now. Thanks!!!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.