怎么加qq328204671

QT中添加Q_OBJECT出现的问题 - CSDN博客
QT中添加Q_OBJECT出现的问题
我在用class My_Node : public QGraphicsItem,public QObject来生成自己的类时,想使用信号和槽机制,但这是dys_node.h中没有Q_OBJECT,不能使用信号槽。我将Q_OBJECT加上之后,出现几个不知道是什么的错误。然后我将工程目录下的Makefile删除,然后重新编译、链接文件,刚才的错误消失了,但出现如下三个错误:
&&&&&&&& error: 'staticMetaObject' is not a member of 'QGraphicsItem'
&&&&&&& &error: 'qt_metacast' is not a member of 'QGraphicsItem'
&&error: 'qt_metacall' is not a member of 'QGraphicsItem'
通过google,我发现这个错误是由于没有继承QObject类而引起的,但是我已经继承了QObject类了啊,到底是怎么回事呢?
最后终于在网上找到了***,当多继承的时候,要将QObject放在前面,即将类的声明改为
class My_Node : public QObject,public QGraphicsItem
问题就解决了!!!
&&& 下面是我从网络上找到的说明原文:
Just got this error message while compiling a tiny class that derives from QTreeWidgetItem:
error C2039: 'staticMetaObject' : is not a member of 'QTreeWidgetItem'
What this is saying is that QTreeWidgetItem does not inherit from QObject, meaning that your own, singly-inherited class also does not inherit from QObject. Inheriting from QObject is
to using the Q_OBJECT macro, which, if you&re anything like me, you automatically insert into any Qt GUI related class.
If you&re not using any of the meta object stuff in your subclass, such as signals/slots or properties, just take out the Q_OBJECT macro. If you need to use signals and slots, you&ll need to make your subclass multiply-inherit from QObject as well. If you take this route, remember that &&, otherwise you&ll get either the same error as above, or something along the lines of &YourClass inherits from two QObject subclasses& from the moc。
本文已收录于以下专栏:
相关文章推荐
Multiple Inheritance Requires QObject to Be First(多重继承QObject一定要放在前面)
我在用class My_Node : public Q...
由于Qt本身实现的机制所限,我们在使用Qt制作某些软件程序的时候,会遇到各种各样这样那样的问题,而且很多是很难,或者根本找不到原因的,即使解决了问题,如果有人问你为什么,你只能回答--不知道。 
使用qobject_cast时遇到的问题
void Optimask::currentCellTreeChanged(int index){
CCellTreeWidget *celltree...
Q_OBJECT宏的作用 The Q_OBJECT macro at the beginning of the class definition is necessary for all classe...
在Qt中,如果一个类要使用信号/槽功能,就必须在其中声明Q_OBJECT,例如Qt5.4.2中QGLWidget说明文档的中的一个例子:
class MyGLDrawer : public QGLW...
Multiple Inheritance Requires QObject to Be First(多重继承QObject一定要放在前面)
我在用class My_Node : public QGra...
现在Qt官方并不是很推荐继承QThread来实现多线程方法,而是极力推崇继承QObject的方法来实现,当然用哪个方法实现要视情况而定,别弄错了就行,估计Qt如此推崇继承QObject的方法可能是QT...
直接继承QObject通常是不行的,需要编写一个类继承QObject, 然后再编写实体类继承这个抽象类
例如编写一个Manager继承QObject
#ifndef MANAGER_H
QWidget是所有窗口中父类,但有时候,我们需要给它重写一些方法,比如mouseDoubleClickEvent事件等,这样一来,我们就会想到写个类,来继承QWidget,自然,我们就写下了如下代码...
我们知道Qt 不是使用的“标准的” C++ 语言,而是对其进行了一定程度的“扩展”。这里我们从Qt新增加的关键字就可以看出来:signals、slots 或者 emit。所以有人会觉得 Qt
他的最新文章
讲师:吴岸城
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)当前位置:&>&&>&
教你免费给自己QQ号码后面加上“靓”字的方法
作者: 围观...次
教你免费给自己QQ号码后面加上&靓&字的方法 是根据之前QQ号码倒置的方法衍生出来的 当然了 爱Q生活网 也感谢各位积极 实现效果如下 1:QQ号码倒置 昵称不变,号码后面可以打一个靓字 效果图如下:
& 2:操作过程录像如下(转自)
& 文字说明:打完自己QQ昵称后,点鼠标右键,然后按键盘的 I键V键盘后& 输入&&字 保存即可 当然了 这个大家可以自己发挥,比如输入 靓字可以改成任意你需要的字都可以! & 方法不保证长期有效!亲测 2009 SP5 SP6& QQ2010 均可以显示(非本地) 转载请注明转自己爱Q生活网 & 4月26更新 修改后号码不倒置的方法&
...人参与 看完本文此刻的感受是?
本站最新更新
··········

参考资料

 

随机推荐