为什么Qt在基类中寻找我的槽而不是派生的? [英] Why is Qt looking for my slot in the base class instead of derived one?
本文介绍了为什么Qt在基类中寻找我的槽而不是派生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的类 X
它继承自Qt的类 Base
。我在我的类 X
中声明并定义了 void mySlot()
X的构造函数。但是,当运行我的程序时,我收到一个错误信息,说明在 Base
void mySlot() >
为什么Meta Object Compiler(moc)生成的代码在基类中而不是在我的(派生)类中查找我的槽?
解决方案
是否在派生类上添加了Q_OBJECT宏?
I have my class X
which inherits from Qt's class Base
. I declared and defined void mySlot()
slot in my class X
and I'm connecting some signal to this slot in X's constructor. However, when running my program I get an error message saying there's no such slot as void mySlot()
in the class Base
.
Why is the code generated by Meta Object Compiler (moc) looking for my slot in the base class and not in my (derived) class?
解决方案
Did you add the Q_OBJECT macro on the derived class?
这篇关于为什么Qt在基类中寻找我的槽而不是派生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文