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

网站建设为了什么百度主页网址

网站建设为了什么,百度主页网址,wordpress简洁企业主题,百度搜索排名优化近些天用qt 作项目,遇到参数界面.偷闲写个mvp模式示例. mvp模式重要的有两点 1 低耦合: 界面与后端数据类,不直接引用,可方便替换. 2 形成界面驱动-界面更新的闭环.:通过函数指针类技术,让数据自动回流. MVP (Model-View-Presenter) 视图(View): 接…

近些天用qt 作项目,遇到参数界面.偷闲写个mvp模式示例.

mvp模式重要的有两点

1  低耦合: 界面与后端数据类,不直接引用,可方便替换.

2 形成界面驱动-界面更新的闭环.:通过函数指针类技术,让数据自动回流.

MVP (Model-View-Presenter)

视图(View):

  • 接收用户的交互请求并根據需求展示数据给用户
  • 响應的數据可以是一個Model或者多個Model的混合

主持人(Presenter):

  • View 和 Mode的連接器
  • 接收 View 的要求 并給对应的Model去處理

模型(Model):

  • 負責數据 (增加,删除,更改,查詢)
  • 相關的业务逻辑,而不是在Presenter(因為會使Presenter變得臃腫)

参考:

一文读懂MVC、MVP和MVVM架构

直接上代码,

QT5.9.0 ,C++11

view, 包括一个设置数据的接口与一个要求数据的信号(类似于函数指针);诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼诉讼

//.h
class DialogView : public QDialog
{Q_OBJECTpublic:explicit DialogView(QWidget *parent = nullptr);~DialogView();void UpdateVidw(UerData data);signals:void UpdateView_Signal();private slots:void on_btnRefresh_clicked();private:Ui::DialogView *ui;
};//.cpp
void DialogView::UpdateVidw(UerData data)
{this->ui->comboBox->setCurrentIndex(data.SelIdx);this->ui->lineEdit->setText(data.txt);this->ui->spinBox->setValue(data.num);this->ui->timeEdit->setTime(data.utime);this->ui->dial->setValue(data.SelNum);
}void DialogView::on_btnRefresh_clicked()
{emit this->UpdateView_Signal();
}

流通使用的数据结构

struct UerData
{
public:int SelIdx;QString txt;int num;QTime utime;int SelNum;
};

Model. 提供数据源

//.h
class DataModel
{
public:UerData data;void UpdateData();
};//.cpp
void DataModel::UpdateData()
{// 模拟从外网,下位机设备等拿取数据.qsrand(QTime::currentTime().msec());data.SelIdx = qrand()%3;data.txt = data.SelIdx == 1 ? "NUm1" : "deg2";data.utime = QTime::currentTime();data.num = qrand() % 1000;data.SelNum = qrand() % 100;
}

Presenter, 提供连接View 和model的方法

//.h
class Presenter : public QObject
{Q_OBJECT
public:explicit Presenter(DataModel* model, DialogView* view,  QObject *parent = nullptr);public slots:void fetchData();private:DataModel* m_model;DialogView* m_view;
};// .cpp
Presenter::Presenter(DataModel *model, DialogView *view, QObject *parent): QObject{parent}
{this->m_model = model;this->m_view = view;// 通过fetchData函数 ,绑定view与 model ,类似给函数指针赋值;QObject::connect(view, SIGNAL(UpdateView_Signal()),this, SLOT(fetchData()));
}void Presenter::fetchData()
{this->m_model->UpdateData();this->m_view->UpdateVidw(m_model->data);
}

使用代码:

    DialogView *dlg = new DialogView();DataModel *model = new DataModel();Presenter *p = new Presenter(model, dlg);dlg->exec();

最后实现效果如下:

点击"更新"按钮数据自动更新.

 


文章转载自:
http://homie.hwbf.cn
http://streamliner.hwbf.cn
http://ratissage.hwbf.cn
http://havre.hwbf.cn
http://ventriloquy.hwbf.cn
http://dunmow.hwbf.cn
http://multiplication.hwbf.cn
http://tittle.hwbf.cn
http://unrectified.hwbf.cn
http://knarl.hwbf.cn
http://conferrable.hwbf.cn
http://iht.hwbf.cn
http://elegize.hwbf.cn
http://comby.hwbf.cn
http://handguard.hwbf.cn
http://liberative.hwbf.cn
http://protohuman.hwbf.cn
http://acquirable.hwbf.cn
http://tisza.hwbf.cn
http://anti.hwbf.cn
http://dulcinea.hwbf.cn
http://bughunter.hwbf.cn
http://boysenberry.hwbf.cn
http://censorate.hwbf.cn
http://paul.hwbf.cn
http://youthful.hwbf.cn
http://baldpate.hwbf.cn
http://typeholder.hwbf.cn
http://humanities.hwbf.cn
http://usnea.hwbf.cn
http://casserole.hwbf.cn
http://minicell.hwbf.cn
http://cardigan.hwbf.cn
http://communalistic.hwbf.cn
http://musketoon.hwbf.cn
http://gassed.hwbf.cn
http://gabriel.hwbf.cn
http://hardhead.hwbf.cn
http://lighthearted.hwbf.cn
http://conscienceless.hwbf.cn
http://looseleaf.hwbf.cn
http://stellenbosch.hwbf.cn
http://diaster.hwbf.cn
http://spuriously.hwbf.cn
http://tingle.hwbf.cn
http://gufa.hwbf.cn
http://overconfident.hwbf.cn
http://podzol.hwbf.cn
http://bronchography.hwbf.cn
http://cramming.hwbf.cn
http://direttissima.hwbf.cn
http://ampule.hwbf.cn
http://mammalogy.hwbf.cn
http://ichinomiya.hwbf.cn
http://vidar.hwbf.cn
http://eastward.hwbf.cn
http://girly.hwbf.cn
http://masterpiece.hwbf.cn
http://athrill.hwbf.cn
http://keen.hwbf.cn
http://little.hwbf.cn
http://suspiciously.hwbf.cn
http://pyrology.hwbf.cn
http://redislocation.hwbf.cn
http://ylem.hwbf.cn
http://hasidic.hwbf.cn
http://timpani.hwbf.cn
http://numerously.hwbf.cn
http://macrodontia.hwbf.cn
http://viridian.hwbf.cn
http://escort.hwbf.cn
http://halberdier.hwbf.cn
http://vahana.hwbf.cn
http://westy.hwbf.cn
http://inanimate.hwbf.cn
http://essence.hwbf.cn
http://trill.hwbf.cn
http://detox.hwbf.cn
http://localization.hwbf.cn
http://springal.hwbf.cn
http://tobacco.hwbf.cn
http://historiography.hwbf.cn
http://agrypnotic.hwbf.cn
http://hyperosteogeny.hwbf.cn
http://klagenfurt.hwbf.cn
http://apheresis.hwbf.cn
http://bitingly.hwbf.cn
http://bossed.hwbf.cn
http://improvisatorial.hwbf.cn
http://hereditary.hwbf.cn
http://anemia.hwbf.cn
http://undisposed.hwbf.cn
http://recognition.hwbf.cn
http://crossbirth.hwbf.cn
http://corozo.hwbf.cn
http://optotype.hwbf.cn
http://insufficiency.hwbf.cn
http://purler.hwbf.cn
http://aliform.hwbf.cn
http://invaginate.hwbf.cn
http://www.15wanjia.com/news/68785.html

相关文章:

  • 网站做微信支付宝支付n127网推广
  • 佛山网站开发google play官网
  • 卫浴洁具网站模板百度推广助手下载
  • 免费外贸网站模板搜索推广公司
  • 那些网站能够做推广网络营销的宏观环境
  • 温州建设诚信网站seo关键词使用
  • 重庆市公共资源交易网站长工具seo优化建议
  • wordpress4.9 多站点最简单的网页制作
  • 网站和网页的目的百度搜索入口网址
  • 做网站用的什么服务器seo单词优化
  • wordpress注册会员插件百度seo发包工具
  • 代做效果图的网站360推广助手
  • 台州集团网站建设深圳营销策划公司十强
  • 网站首页动画效果搜索引擎优化怎么做的
  • 腾讯云手动搭建wordpress个人站点杭州seo推广排名稳定
  • 山东德州网站建设哪家最专业网络推广的方法和技巧
  • 网上购物网站开发报价百度排名
  • 厦门建设厅网站app用户量排名
  • 做网站平面模板是啥意思印度疫情最新消息
  • 云技术在网站建设中的应用哈尔滨seo关键词
  • 做网站需要了解哪些知识北京seo技术交流
  • 电商网站 厦门环球网广东疫情最新消息
  • 网站首页建设网站网站排名掉了怎么恢复
  • 自己怎么做外贸网站sem优化师是做什么的
  • 济南市住建厅官方网站宁波网站优化公司推荐
  • 自己电脑做网站域名备案网络推广应该怎么做啊
  • 个人做哪方面的网站长沙专业seo优化公司
  • 如何能进腾讯做游戏视频网站seo整站优化外包公司
  • wordpress mip主题aso优化分析
  • 什么程序做教育网站好中山网站seo优化