继承QTreeWidgetItem发生staticMetaObject错误

error: no member named 'staticMetaObject' in 'QTreeWidgetItem'; did you mean simply 'staticMetaObject'?

网上找了好多,最后总结下

原代码:

#ifndef ESTREEWIDGETITEM_H
#define ESTREEWIDGETITEM_H

#include 
#include 


class EsTreeWidgetItem : public QTreeWidgetItem
{
    Q_OBJECT
public:
    explicit EsTreeWidgetItem(QTreeWidget *parent, const QStringList &strings,int type = Type);

signals:

public slots:
};

#endif // ESTREEWIDGETITEM_H

修改成

#ifndef ESTREEWIDGETITEM_H
#define ESTREEWIDGETITEM_H

#include 
#include 


class EsTreeWidgetItem : public QObject,public QTreeWidgetItem
{
    Q_OBJECT
public:
    explicit EsTreeWidgetItem(QTreeWidget *parent, const QStringList &strings,int type = Type);

signals:

public slots:
};

#endif // ESTREEWIDGETITEM_H

即:将QWidget继承在前面

你可能感兴趣的:(qt)