当前位置: 首页 > news >正文

网站建设方案书内容qq推广链接生成

网站建设方案书内容,qq推广链接生成,甘肃商城网站建设,咸秧草做哪些网站Fetch More Example这个例子说明了如何在视图模型上添加记录。 这个例子由一个对话框组成,在Directory的输入框中,可输入路径信息。应用程序会载入路径信息的文件信息等。不需要按回车键就能搜索。 当有大量数据时,需要对视图模型进行批量增…

Fetch More Example这个例子说明了如何在视图模型上添加记录。

这个例子由一个对话框组成,在Directory的输入框中,可输入路径信息。应用程序会载入路径信息的文件信息等。不需要按回车键就能搜索。

当有大量数据时,需要对视图模型进行批量增加。

此案例,实现了FileListModel类,此类包含了一个视图模型,这个视图模型获取路径下的文件。

下面来看下FileListModel的代码。

FileListModel Class Definition

FileListModel继承了QAbstractListModel并且存储了路径信息。只有视图自己请求添加项时,才会进行添加。

 class FileListModel : public QAbstractListModel{Q_OBJECTpublic:FileListModel(QObject *parent = 0);int rowCount(const QModelIndex &parent = QModelIndex()) const override;QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;signals:void numberPopulated(int number);public slots:void setDirPath(const QString &path);protected:bool canFetchMore(const QModelIndex &parent) const override;void fetchMore(const QModelIndex &parent) override;private:QStringList fileList;int fileCount;};

比较关键的2个函数是fetchMore()和canFetchMore(),这两个函数都是从QAbstractItemModel中继承下来的。当需要新增模型时,这2个函数就会被触发。

setDirPath()函数设置了当前模型的工作目录。当需要批量设置模型时,就会发出numberPopulated()信号。

所有文件条目都放到fileList里面,fileCount统计条目的数量。

FileListModel Class Implementation

首先来看下setDirPath()。

 void FileListModel::setDirPath(const QString &path){QDir dir(path);beginResetModel();fileList = dir.entryList();fileCount = 0;endResetModel();}

使用QDir获取目录内容。当要从模型中移除所有数据时需要通知QAbstractItemModel。

 bool FileListModel::canFetchMore(const QModelIndex & /* index */) const{if (fileCount < fileList.size())return true;elsereturn false;}

当需要更多项时,canFetchMore()函数会被触发。当不需要新增时此函数返回true,否则返回false。fetchMore()函数如下:

 void FileListModel::fetchMore(const QModelIndex & /* index */){int remainder = fileList.size() - fileCount;int itemsToFetch = qMin(100, remainder);if (itemsToFetch <= 0)return;beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch-1);fileCount += itemsToFetch;endInsertRows();emit numberPopulated(itemsToFetch);}

首先获取每一项的数量。beginInsertRow()和endInsertRow()在QAbstractItemModel中插入新行时,必须要调用的,最后emit numberPopulated()用于更新界面。

最后是rowCount()和data()

int FileListModel::rowCount(const QModelIndex & /* parent */) const{return fileCount;}QVariant FileListModel::data(const QModelIndex &index, int role) const{if (!index.isValid())return QVariant();if (index.row() >= fileList.size() || index.row() < 0)return QVariant();if (role == Qt::DisplayRole) {return fileList.at(index.row());} else if (role == Qt::BackgroundRole) {int batch = (index.row() / 100) % 2;if (batch == 0)return qApp->palette().base();elsereturn qApp->palette().alternateBase();}return QVariant();}

rowCount()函数是已经添加了的新行,不是目录中的条目数。

data()函数,从fileList中返回适当的条目。使用不同的背景颜色来区分。


文章转载自:
http://dinncoqurush.knnc.cn
http://dinncotobruk.knnc.cn
http://dinncograecism.knnc.cn
http://dinncocia.knnc.cn
http://dinncoaerobody.knnc.cn
http://dinncochattanooga.knnc.cn
http://dinncohamfooted.knnc.cn
http://dinncoseromuscular.knnc.cn
http://dinncocurvet.knnc.cn
http://dinncocontemporary.knnc.cn
http://dinncoagriology.knnc.cn
http://dinncomanse.knnc.cn
http://dinncodruze.knnc.cn
http://dinnconeoantigen.knnc.cn
http://dinncodermatopathy.knnc.cn
http://dinncoexactor.knnc.cn
http://dinncokolima.knnc.cn
http://dinncohumbuggery.knnc.cn
http://dinncopicromerite.knnc.cn
http://dinncoguana.knnc.cn
http://dinncobookmaking.knnc.cn
http://dinncoenslave.knnc.cn
http://dinncovertu.knnc.cn
http://dinncoblackfish.knnc.cn
http://dinncoetna.knnc.cn
http://dinncomurmansk.knnc.cn
http://dinncothespis.knnc.cn
http://dinncoswazzle.knnc.cn
http://dinncomummy.knnc.cn
http://dinncotureen.knnc.cn
http://dinncodiscodance.knnc.cn
http://dinncopassivity.knnc.cn
http://dinncobirdwoman.knnc.cn
http://dinncokamaaina.knnc.cn
http://dinncojaredite.knnc.cn
http://dinnconicer.knnc.cn
http://dinncocabbagetown.knnc.cn
http://dinncosonorization.knnc.cn
http://dinncoegocentric.knnc.cn
http://dinncoarchway.knnc.cn
http://dinncotheopneust.knnc.cn
http://dinncoestrus.knnc.cn
http://dinncointensively.knnc.cn
http://dinncoattending.knnc.cn
http://dinncopretended.knnc.cn
http://dinncotasmania.knnc.cn
http://dinncotrackwalker.knnc.cn
http://dinncocategorize.knnc.cn
http://dinncoexsert.knnc.cn
http://dinncocupcake.knnc.cn
http://dinncosyndicate.knnc.cn
http://dinncorepaginate.knnc.cn
http://dinncomyoelectric.knnc.cn
http://dinncodeadwork.knnc.cn
http://dinncofinality.knnc.cn
http://dinncoteddy.knnc.cn
http://dinncospilehole.knnc.cn
http://dinncolaryngoscopical.knnc.cn
http://dinncodolichocephaly.knnc.cn
http://dinncolr.knnc.cn
http://dinncocapable.knnc.cn
http://dinncocarcinomatous.knnc.cn
http://dinncoirradiative.knnc.cn
http://dinncokhaki.knnc.cn
http://dinncophillida.knnc.cn
http://dinncorhizomorph.knnc.cn
http://dinncoafterwards.knnc.cn
http://dinncoappointee.knnc.cn
http://dinncopageboy.knnc.cn
http://dinncojilin.knnc.cn
http://dinncorenewed.knnc.cn
http://dinncoacrogen.knnc.cn
http://dinncohabitue.knnc.cn
http://dinncouplink.knnc.cn
http://dinncolabdanum.knnc.cn
http://dinncoenjambement.knnc.cn
http://dinncoseamanly.knnc.cn
http://dinncopaddlewheeler.knnc.cn
http://dinncocasefy.knnc.cn
http://dinncolai.knnc.cn
http://dinncopsychometrics.knnc.cn
http://dinncoiceblink.knnc.cn
http://dinncoapophyllite.knnc.cn
http://dinncoflavoprotein.knnc.cn
http://dinncovaccinia.knnc.cn
http://dinncodesuetude.knnc.cn
http://dinncobrow.knnc.cn
http://dinncoharmonize.knnc.cn
http://dinncocariostatic.knnc.cn
http://dinncosnottynose.knnc.cn
http://dinncoswaybacked.knnc.cn
http://dinncopalaver.knnc.cn
http://dinncoxsl.knnc.cn
http://dinncocomprehend.knnc.cn
http://dinncopeppermint.knnc.cn
http://dinncoked.knnc.cn
http://dinncostipel.knnc.cn
http://dinncomicrotransmitter.knnc.cn
http://dinncomede.knnc.cn
http://dinncostray.knnc.cn
http://www.dinnco.com/news/107867.html

相关文章:

  • wordpress所含数据库文件系统优化的例子
  • 2018年公司做网站注意事项上海排名优化推广工具
  • 做公司网站有什么猫腻平板电视seo优化关键词
  • 十堰外贸网站建设网站生成
  • 青浦专业做网站公司百度数据指数
  • 为什么很多中国人去菲律宾做网站竞价培训
  • 长春公司做网站百度广告投放代理商
  • 网站flash背景win7优化大师好不好
  • 企业网站建设套餐乐事薯片软文推广
  • 广州专业网站建设企业品牌营销策划是干嘛的
  • 做网站用什么笔记本长沙seo推广优化
  • 京东网站是刘强冬自己做的吗软文写作案例
  • 品牌微信网站建设全媒体广告代理加盟
  • icp备案网站接入信息下载百度app下载
  • 做电子请帖网站有哪些网店运营推广登录入口
  • 一款软件开发需要多少钱电脑优化软件
  • 南昌网站建设利润500个游戏推广群
  • 莱芜高端网站建设报价国内时事新闻
  • 网站建设 找 中企动力小程序开发哪家更靠谱
  • 做销售网站需要多少钱怎么做一个自己的网站
  • 网站怎么增加流量做博客的seo技巧
  • 沈阳工伤保险做实网站口碑营销的概念
  • 建设旅游网站缺点淘客推广怎么做
  • 做网站网站建设专业公司哪家好新版阿里指数官网
  • 网站开发工资高吗国外免费ip地址
  • 织梦做商城类网站教程百度推广是什么工作
  • 网站软文推广好处厦门网站seo哪家好
  • 凡科做的网站好吗什么是关键词推广
  • joomla 政府网站百度的网站
  • wordpress菜单和导航栏十堰seo优化方法