Qt - no such signal error

回眸只為那壹抹淺笑 提交于 2019-12-01 03:52:09

Put the Q_OBJECT macro at the top, (must be first thing in the class and no ";" )

Make sure you do a full rebuild, the VS-add-in especially doesn't always notice that a file has become qt-aware without a rebuild.

More good advice 20 ways to debug Qt signals and slots

Odys

It WAS the macro in the end. I had to reboot my PC for it to work though, cleaning and rebuilding the project didn't work out. Before rebooting Qt Creator kept giving the 'ld returned 1 exit status' error and the vtable warnings. Really weird. – David McDavidson

It's not weird, it's stupid. I got the same error, but I make it after rearrange the .h files. Say:

1 classA.h include calssB.h ;

2 classB.h declared two class, classB and classC, (classB.h declared signals & slot)

I do three things,

  1. seperate classC to another .h file

  2. eliminate all forward class declaration about classB

  3. classB.h included by classA.cpp, other than by classA.h

after that, QT compiled it. I'll test if it is working.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!