问题描述
我一直在为 Qt 上的问题苦苦挣扎.
I have been struggling for a while with an issue on Qt.
这是我的代码:
hexbutton.h:
hexbutton.h:
Hexbutton.cpp:
Hexbutton.cpp:
MyWindow.h:
MyWindow.h:
MyWindow.cpp:
MyWindow.cpp:
最后,Main.cpp:
And finally, Main.cpp:
以防万一,这里是 Test.pro
Just in case, here is the Test.pro
我得到了 2 个错误:
And I get the 2 errors:
1) 找不到架构 x86_64 的符号
1) symbol(s) not found for architecture x86_64
2) collect2: ld 返回 1 个退出状态
2) collect2: ld returned 1 exit status
它还说 121 次 (11*11):
It also says 121 times (11*11):
Object::connect: ../Test/MyWindow.cpp:19 中没有这样的插槽 QPushButton::changeIcon()
Object::connect: No such slot QPushButton::changeIcon() in ../Test/MyWindow.cpp:19
在编译输出上它说:
显然错误来自 Q_OBJECT(插槽定义需要),但我的代码有问题,而不是我的编译器(因为当插槽位于 MainWindow 时,它工作正常).
Apparently the error comes from the Q_OBJECT (needed for the slots definition), but there is something wrong with my code, not with my compiler (because I have when slots are in MainWindow, it works fine).
感谢您的帮助!
推荐答案
遇到同样的问题
- 我的信号未定义的参考误差.
- 放入 Q_OBJECT 宏后... vtable 错误.
我这样做并为我工作
- 在文件中添加了 Q_OBJECT
- 清理项目
- 跑qmake
- 重建
它编译得很好.
这篇关于错误:找不到架构 x86_64 的符号,collect2:ld 返回 1 个退出状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!