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

做租赁的行业网站seo网址查询

做租赁的行业网站,seo网址查询,基础网站建设,杨凌做网站的1.简介 QAbstractListModel类提供了一个抽象模型#xff0c;可以将其子类化以创建一维列表模型。 QAbstractListModel为将其数据表示为简单的非层次项目序列的模型提供了一个标准接口。它不直接使用#xff0c;但必须进行子类化。 由于该模型提供了比QAbstractItemModel更…1.简介 QAbstractListModel类提供了一个抽象模型可以将其子类化以创建一维列表模型。 QAbstractListModel为将其数据表示为简单的非层次项目序列的模型提供了一个标准接口。它不直接使用但必须进行子类化。 由于该模型提供了比QAbstractItemModel更专业的接口因此不适合与树视图一起使用如果您想提供一个用于此目的的模型则需要对QAbstractItemModel进行子类化。如果您需要使用多个列表模型来管理数据则可能更适合使用子类QAbstractTableModel。 继承QAbstractListModel需要重写rowCount()、data()、insertRows()、removeRows()等函数。 rowCount()函数返回模型的行数。data()函数返回指定索引处的数据。insertRows()插入行removeRows()删除行 2.示例 #ifndef MYLISTMODEL_H #define MYLISTMODEL_H#include QAbstractListModel #include QObject #include QListtypedef struct _student {QString name;int age;double score; }Student;class MyListModel : public QAbstractListModel {Q_OBJECT public:MyListModel(QObject *parent nullptr);enum RoleNames{Name,Age,Score};public://更新void update(QListStudent students);// 返回列表中行的数量virtual int rowCount(const QModelIndex parent QModelIndex()) const;// 返回指定索引处的数据virtual QVariant data(const QModelIndex index, int role Qt::DisplayRole) const;//插入行virtual bool insertRows(int row, int count, const QModelIndex parent QModelIndex());//删除行virtual bool removeRows(int row, int count, const QModelIndex parent QModelIndex());private:QListStudent m_lstStu; };#endif // MYLISTMODEL_H#include MyListModel.hMyListModel::MyListModel(QObject *parent): QAbstractListModel(parent) {}void MyListModel::update(QListStudent students) {m_lstStu students;for(int i0;im_lstStu.size();i){beginInsertRows(QModelIndex(),i,i);endInsertRows();} }int MyListModel::rowCount(const QModelIndex parent) const {Q_UNUSED(parent);return m_lstStu.size(); }QVariant MyListModel::data(const QModelIndex index, int role) const {if(!index.isValid())return QVariant();int nRow index.row();Student stu m_lstStu.at(nRow);if (role Qt::DisplayRole || role Qt::EditRole){QString ret QString(%1_%2_%3).arg(stu.name).arg(stu.age).arg(stu.score);return ret;}return QVariant(); }bool MyListModel::insertRows(int row, int count, const QModelIndex parent) {if (row 0 row m_lstStu.size()){beginInsertRows(parent, row, row count - 1);for (int i 0; i count; i){//插入一个空的数据Student stu;stu.name QString();stu.age 0;stu.score 0;m_lstStu.insert(row, stu);}endInsertRows();return true;}return false; }bool MyListModel::removeRows(int row, int count, const QModelIndex parent) {if (row 0 row count m_lstStu.size()){beginRemoveRows(parent, row, row count - 1);for (int i 0; i count; i){m_lstStu.removeAt(row);}endRemoveRows();return true;}return false; } 使用 #include ListForm.h #include ui_ListForm.h #include MyListModel.hMyListModel *pModel nullptr;ListForm::ListForm(QWidget *parent) :QWidget(parent),ui(new Ui::ListForm) {ui-setupUi(this);//去除选中虚线框ui-listView-setFocusPolicy(Qt::NoFocus);//设置整行选中ui-listView-setSelectionBehavior(QAbstractItemView::SelectRows);pModel new MyListModel(this);// 构造数据更新界面QListStudent students;QListQString nameList;nameList张三李四王二赵五刘六;for (int i 0; i 5; i){Student student;student.name nameList.at(i);student.age qrand()%6 13;//随机生成13到19的随机数student.score qrand()%20 80;//随机生成0到100的随机数;students.append(student);}pModel-update(students);ui-listView-setModel(pModel); }ListForm::~ListForm() {delete ui; }void ListForm::on_btnInsert_clicked() {if(!pModel)return;int row ui-listView-currentIndex().row();if(row 0)return;pModel-insertRows(row1,1); }void ListForm::on_btnDel_clicked() {if(!pModel)return;int row ui-listView-currentIndex().row();if(row 0)return;pModel-removeRows(row,1); }
http://www.zqtcl.cn/news/923737/

相关文章:

  • 北京微网站建设设计服务营销导向的企业网站建设步骤
  • 网站 301网站设计评价标准
  • 网站页面设计规范大连装修公司哪家好
  • 祁东网站建设微信公众号做的网站
  • 火山开发软件可以开发网站吗盐城代运营
  • 网页制作与网站建设从入门到精通民宿客栈网站制作
  • 如何写手机适配网站自己做的网站能上传到凡科吗
  • 建设公司网站开发方案seo优化工具的种类
  • 没备案的网站怎么做淘客企业做网站服务费
  • 网址站点异常怎么解决机关单位建设网站 说明
  • 阿虎手机站青岛关键词排名系统
  • 西安网站建设聚星互联网站成功案例
  • 山东鲁为建设集团网站百度的合作网站有哪些
  • 电子商务网站建设与管理程序设计题6哪家微网站做的好
  • 网站建设图文片平面网页设计是什么
  • 域外网站宁波建设监理协会
  • 胶州网站建设公司哪家好wordpress怎么改标题
  • php网站开发综合案例免费注册推广网站
  • 邯郸做网站的地方广州网站制作
  • 企业网站制作公司24小时接单郑州手机网站推广外包
  • 接做施工图的网站手机移动网站模板
  • 做网站月薪资多少钱如何打开微信小程序
  • 免费建站网站一级大录像不卡在线看网页无锡网站排名提升
  • 无锡门户网站制作服务郑州艾特网站建设
  • 建设网站 万网网页设计表单代码模板
  • 网站速度查询app开发模板网站
  • 国外案例网站做电商网站有什么用
  • 自己做的网站点击赚钱免费制作二级网站
  • 产品包装设计网站网站开发所需费用
  • 新手学做百度联盟网站html水平导航栏怎么做