Это мое определение класса Container
class Container
{
private:
std::string stdstrContainerName;
std::string stdstrPluginType;
std::string stdstrPluginName;
int iSegments;
float fRadius;
public:
Container();
explicit Container(std::string strContainerName , std::string
strPluginName , std::string strPluginType, int segments , float
radius );
~Container();
std::string GetName();
std::string GetType();
void SetName(std::string stdstrName);
};
Я хочу, чтобы узлы TreeView содержали объект класса Container как данные.
Это файл заголовка для класса TreeItem.
class TreeItem
{
public:
explicit TreeItem( const Container &data , TreeItem *parent = 0 );
~TreeItem();
TreeItem *parent();
TreeItem *child(int iNumber);
int childCount() const;
int childNumber() const;
Container data() const;
bool setData(const Container &data);
bool insertChildren(int position, int count );
bool removeChildren( int position , int count );
private:
QList<TreeItem*> childItems;
Container itemData;
TreeItem* parentItem;
};
Проблема, с которой я сталкиваюсь, заключается в реализации функций TreeModel.Как я могу использовать контейнер в качестве типа данных вместо QVariant.
QVariant data(const QModelIndex &undex, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
bool setData( const QModelIndex &index , const QVariant &value , int
role = Qt::EditRole) override;