error: no member named 'staticMetaObject' in 'QTreeWidgetItem'; did you mean simply 'staticMetaObject'?
网上找了好多,最后总结下
原代码:
#ifndef ESTREEWIDGETITEM_H
#define ESTREEWIDGETITEM_H
#include <QWidget>
#include <QTreeWidgetItem>
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 <QWidget>
#include <QTreeWidgetItem>
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继承在前面