Solved Unresolved external symbol when connecting with new syntax
-
LdLineEdit
-
@Mwoua
And What is LdLineEdit ? -
Strange error. replace
private slots:
withprotected:
btw, the event is not a slot. Also add a constructor or you'll potentially break parent/child dependency.Last question, what is
LD_DLL
?class LdLineEdit: public QLineEdit { Q_OBJECT Q_DISABLE_COPY(LdLineEdit) public: LdLineEdit(QWidget* parent = Q_NULLPTR) :QLineEdit(parent) {} signals: LD_DLL void LdClicked(); protected: void mouseReleaseEvent(QMouseEvent *){emit LdClicked();} }
-
@Taz742
See first post@VRonin
The constructor is there in my class, I forgot it because I wanted to simplify (I'll edit my first post)The macro is :
#if defined(LD_LIBRARY) # define LD_DLL Q_DECL_EXPORT #else # define LD_DLL Q_DECL_IMPORT #endif
LdLineEdit is in a dll that I use in my other function
Same issue with the function in protected.
EDIT : it might be linked to the dll, if I do this inside a function of LdLineEdit :
connect( this, &LdLineEdit::LdClicked, this, &LdLineEdit::ThisValueChanged);
It compiles (ThisValueChanged is private slot of LdLineEdit)
-
@Mwoua said in Unresolved external symbol when connecting with new syntax:
LdLineEdit is in a dll
BINGO!
you should export the whole classclass LD_DLL LdLineEdit: public QLineEdit { Q_OBJECT Q_DISABLE_COPY(LdLineEdit) public: LdLineEdit(QWidget* parent = Q_NULLPTR) :QLineEdit(parent) {} signals: void LdClicked(); protected: void mouseReleaseEvent(QMouseEvent *){emit LdClicked();} }
-
Export the whole class, not only a handful of methods.
Edit: Crossposted with our Ronin, but it happens. ;)
-
Ok, is there a rule to export a whole class or just a part of it?
-
The rule is you need to export Qt's methods and variables from your class - the ones
Q_OBJECT
introduces (in this case thestaticMetaObject
, see your linker error in the OP), so when working withQObject
s always export the whole class. -
Thanks for the help !
-
No problem. As to why it works with the old syntax - it works because there's no compile time checking and all is done in runtime.