QStringListModel

 

QStringListModel类提供了一个模型,该模型向视图提供字符串。

QStringListModel是一个可编辑的模型,可用于需要在视图小部件(如QListView或QComboBox)中显示多个字符串的简单情况。

该模型提供可编辑模型的所有标准函数,将字符串列表中的数据。
使用data()函数读取项数据,并使用setData()写入项数据。可以使用rowCount()函数找到行数(以及字符串列表中的项数)。
可以使用现有的字符串列表构造模型,也可以稍后使用setStringList()便利函数设置字符串。字符串也可以用insertRows()函数以通常的方式插入,并用removeows()删除。字符串列表的内容可以使用stringList()便利函数检索。

An example usage of QStringListModel:

    QStringListModel *model = new QStringListModel();
    QStringList list;
    list << "a" << "b" << "c";
    model->setStringList(list);



Reimplemented Public Functions

virtual QVariant	data(const QModelIndex & index, int role) const
virtual Qt::ItemFlags	flags(const QModelIndex & index) const
virtual bool	insertRows(int row, int count, const QModelIndex & parent = QModelIndex())
virtual bool	removeRows(int row, int count, const QModelIndex & parent = QModelIndex())
virtual int	rowCount(const QModelIndex & parent = QModelIndex()) const
virtual bool	setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole)
virtual QModelIndex	sibling(int row, int column, const QModelIndex & idx) const
virtual void	sort(int column, Qt::SortOrder order = Qt::AscendingOrder)
virtual Qt::DropActions	supportedDropActions() const

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值