0

I get "LNK2019: unresolved external symbol" error when trying to create new slot in any window class with standard C++ library arguments.

private slots:
    ...

    void setNewTableItemFromDialog(int number, int age, string rate, string name, string team);

    ...
private slots:
    void replaceTableItem(int number, int age, string rate, string name, string team);

For some reason Qt can compile "setNewTableItemFromDialog()" method, but can't do this with "replaceTableItem()" method, whicn contains actually the same arguments. If I remove this particular method, all works just fine. I already tried to delete build derectory, run CMake, and clean project, nothing works.

Here is full error description screenshot

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Nikita
  • 11
  • 1
  • 1
    Did you provide a definition for replaceTableItem in the implementation file? – Matt Eding Dec 29 '20 at 02:29
  • @MattEding Oh, that's it! Thank you. Why do i can compile files with QString argument without definition, but can't with this types? – Nikita Dec 29 '20 at 02:44
  • You shouldn't be able to compile slots without a definition -- perhaps you are confusing it with signals which have their definitions created by Qt's MOC. As an aside, you should probably stick to using QString when working with Qt, but if you must work with non-Qt types, you will need to register them `qRegisterMetaType`. – Matt Eding Dec 29 '20 at 02:49

0 Answers0