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

推广网站的方法铭万做网站怎么样

推广网站的方法,铭万做网站怎么样,内蒙古呼和浩特邮编,航拍类wordpress模板参考#xff1a;QT(7)-初识委托_qt 委托-CSDN博客 一、 1、 模型#xff1a;负责“组织”数据#xff1b; 视图#xff1a;负责“显示”数据#xff1b; 委托#xff1a;负责“修改”数据#xff1b; 2、委托#xff1a;在QT的MV模型中#xff0c;处理特定类型的…参考QT(7)-初识委托_qt 委托-CSDN博客 一、 1、 模型负责“组织”数据 视图负责“显示”数据 委托负责“修改”数据 2、委托在QT的MV模型中处理特定类型的数据控制数据的外观和行为 定制 数据 的“显示”和“编辑” 编辑日期,数值、渲染颜色,字体、 支持文本编辑器,下拉列表编辑器等、 更新编辑器的尺寸、证编辑器中的数据是否合法 3、委托应用场景 3.1表格和列表视图编辑单元格的数据、定制单元格外观 3.2 属性编辑器创建自定义的属性编辑器 3.3 文件对话框定制文件列表的外观 二、QT中的委托类 抽象基类 QAbstractItemDelegate-》QItemDelegate-》QStyledItemDelegate QStyledItemDelegate使用Qt Style Sheets来渲染单元格中的数据这样可以更好地与应用程序的外观保持一致。 三、委托类 关键函数 3.1 virtual函数 createEditor创建用于编辑特定单元格中数据的 编辑器 setEditorData编辑器被创建后被调用用于初始化设置编辑器的值。 setModelData在编辑器编辑完成后被调用用于将编辑器中数据更新到数据模型中 updateEditorGeometry用于设置编辑器的位置和大小。 一般通过继承 QStyledItemDelegate以上4个函数便可以实现简单的自定义委托。 3.2 其他函数 destroyEditor editorEvent helpEvent sizeHint 这些函数并没有重要和非重要之分需要根据不同的需求实现不同的函数达到想要的效果。 四、使用委托 实现功能 4.1 委托 实现功能1创建QSpinBox 编辑器、设置编辑器值、将编辑器中值保存的数据模型、设置编辑器位置 delegate.h文件#ifndef DELEGATE_H #define DELEGATE_H#include QStyledItemDelegate//! [0] class SpinBoxDelegate : public QStyledItemDelegate {Q_OBJECTpublic:SpinBoxDelegate(QObject *parent nullptr);QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem option,const QModelIndex index) const override;void setEditorData(QWidget *editor, const QModelIndex index) const override;void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex index) const override;void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem option,const QModelIndex index) const override; }; //! [0]#endifdelegate.cpp文件#include delegate.h #include QSpinBox//! [0] SpinBoxDelegate::SpinBoxDelegate(QObject *parent): QStyledItemDelegate(parent) { } //! [0]//! [1] QWidget *SpinBoxDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem /* option */,const QModelIndex /* index */) const {QSpinBox *editor new QSpinBox(parent);editor-setFrame(false);editor-setMinimum(0);editor-setMaximum(100);return editor; } //! [1]//! [2] void SpinBoxDelegate::setEditorData(QWidget *editor,const QModelIndex index) const {int value index.model()-data(index, Qt::EditRole).toInt();QSpinBox *spinBox static_castQSpinBox*(editor);spinBox-setValue(value); } //! [2]//! [3] void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex index) const {QSpinBox *spinBox static_castQSpinBox*(editor);spinBox-interpretText();int value spinBox-value();model-setData(index, value, Qt::EditRole); } //! [3]//! [4] void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,const QStyleOptionViewItem option,const QModelIndex /* index */) const {editor-setGeometry(option.rect); } //! [4]createEditor函数中定义了一个 QSpinBox类型的编辑器并对其进行了简单的初始化和设置 setEditorData函数中将模型中index位置的数据拿了出来并保存在了value中并将value设置到了编辑器中 setModelData函数中将编辑器中的数据取出来设置到模型中 updateEditorGeometry中对位置进行了设置editor-setGeometry(option.rect);不执行这个生成的控件在坐标原点 4.2 委托 实现功能2创建QDateEdit 编辑器、设置编辑器值、将编辑器中值保存的数据模型、设置编辑器位置 delegate.cpp文件#include delegate.h #include QSpinBox #include QDateEditQDateEdit::QDateEdit(QObject *parent): QStyledItemDelegate(parent) { }QWidget *QDateEdit::createEditor(QWidget *parent,const QStyleOptionViewItem /* option */,const QModelIndex /* index */) const { // QSpinBox *editor new QSpinBox(parent); // editor-setFrame(false); // editor-setMinimum(0); // editor-setMaximum(100);auto *editor new QDateEdit(parent);editor-setDisplayFormat(yyyy-MM-dd);return editor; }void QDateEdit::setEditorData(QWidget *editor,const QModelIndex index) const { // int value index.model()-data(index, Qt::EditRole).toInt(); // QSpinBox *spinBox static_castQSpinBox*(editor); // spinBox-setValue(value);auto value index.model()-data(index, Qt::EditRole).toDate();QDateEdit *dateEdit static_castQDateEdit*(editor);dateEdit-setDate(value); }void QDateEdit::setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex index) const { // QSpinBox *spinBox static_castQSpinBox*(editor); // spinBox-interpretText(); // int value spinBox-value(); // model-setData(index, value, Qt::EditRole);auto dateEdit static_castQDateEdit*(editor);auto value dateEdit-date();model-setData(index,value,Qt::EditRole); }void QDateEdit::updateEditorGeometry(QWidget *editor,const QStyleOptionViewItem option,const QModelIndex /* index */) const {editor-setGeometry(option.rect); } 五、 按照这个思路那么只要改一下里面的编辑器就能实现不同的委托。想要实现不同的委托只要继承QStyledItemDelegate类并实现相应的函数就可以实现不同的委托。 密码委托下拉框委托QComboBox颜色选择委托图标委托等等甚至包括一些你自己定义的控件的委托。
http://www.zqtcl.cn/news/13123/

相关文章:

  • 佛山网站seo公司网站营销做的好的律师
  • 网站更新步骤郑州网站建设七彩科技
  • 网站建设的关键技术优质的设计网站有哪些
  • 创办网站网站资料筹备
  • 搭建网站不用服务器吗c2c网站建设的需求分析
  • 做app好 还是讯网站好有哪些比较好的做ppt好的网站
  • 学做包子馒头的网站做网站生意买螃蟹
  • 杭州网站建设服务dt模板网
  • 做网站精英网站icp备案信息是什么
  • 做韦恩图的在线网站网络营销的特点决定了它不能满足
  • 网站建设与管理实务义乌加工厂外发加工
  • 青海省住房和建设厅网站本科自考难吗
  • 站长统计app官方网站电子商务网站建设的流程图
  • 葛洲坝机电建设有限公司网站餐馆餐饮装修设计
  • 东川网站建设怎样做网站制作
  • 做网站怎么收费多少wordpress自建邮箱
  • 营销型企业网站建设与推广微信营销的优缺点
  • 网站做产品的审核工作内容网站首页尺寸
  • 关于加强网站建设和管理的通知福州网站制作服务
  • 运河经济开发区建设局网站网站建设客户案例
  • 男女情感类网站连云港做网站哪里好
  • 装饰网站建设运营购物网网站建设
  • 三星网站建设内容台州建设监理协会网站
  • 北京品牌网站建设公司建设银行官网首页网站公告
  • 做网站时给网页增加提醒永康公司网站建设
  • 导购分享网站模板宁波公司注册流程
  • 北京专业制作网站广西建设网查询
  • 提供企业网站建设方案花瓣网 素材 图库
  • 广告公司网站模版手机网站开发位置定位
  • 电商网站后台管理系统模板wordpress商城移动端