你好我在TreeItem类中有一个结构:
// TreeItem.h
class TreeItem
{
public:
struct TreePair
{
QString sa_key;
QVariant sa_value;
};
//... blabla
}
我想从另一个类TreeModel访问该结构TreePair,该类已经在其标题中包含了类TreeItem:
// TreeModel.h
class TreeItem;
class TreeModel : public QAbstractItemModel
{
Q_OBJECT
//..
}
// TreeModel.cpp
TreeModel::TreeModel(const QStringList &headers, const QString &data, QObject *parent)
: QAbstractItemModel(parent)
{
QVector<TreePair> rootData; // TreePair was not declared in this scope
}
我的strcut没有在这个范围内声明?在每个课程中,它已经自动设置为
#ifndef _TREEITEM_H
#define _TREEITEM_H
#endif
答案 0 :(得分:1)
由于TreePair
嵌套在TreeItem
内,因此需要
QVector<TreeItem::TreePair> rootData;