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

网站cms系统 开源乔拓云网微信小程序制作

网站cms系统 开源,乔拓云网微信小程序制作,怎样清除单位域名 网站或互联网网址,医院网站建设的资料一)Model - View - Presenter (MVP) 模式在 TouchGFX 中的应用 1)Model(模型): 模型代表应用程序的数据和业务逻辑。例如,在一个简单的计数器应用中,模型可以是一个包含计数器当前值的类。 class CounterModel { pri…

一)Model - View - Presenter (MVP) 模式在 TouchGFX 中的应用
1)Model(模型):
模型代表应用程序的数据和业务逻辑。例如,在一个简单的计数器应用中,模型可以是一个包含计数器当前值的类。

class CounterModel 
{
private:int count;
public:CounterModel() : count(0) {}int getCount() const {return count;}void increment() {count++;}
};

2)View(视图):
在 TouchGFX 中,视图是通过界面设计工具创建的图形用户界面(GUI)元素。例如,有一个文本框用于显示计数器的值,一个按钮用于增加计数器的值。这些 GUI 元素在 TouchGFX Designer 中设计,然后在代码中通过相关的类来引用。
视图类需要能够更新界面显示,以反映模型的状态变化。以下是一个简单的视图类示例,用于显示计数器的值:

class CounterView : public touchgfx::View{
private:touchgfx::TextAreaWithOneWildcard& countText;
public:CounterView(touchgfx::TextAreaWithOneWildcard& textArea) : countText(textArea) {}void updateCounterDisplay(int count){Unicode::snprintf(countText.getBuffer(), countText.getBufferSize(), "%d", count);countText.invalidate();}
};

3)Presenter(展示器):
展示器作为模型和视图之间的桥梁,它包含对模型和视图的引用,并处理用户交互。当用户点击增加计数器的按钮时,展示器会调用模型的increment方法来更新数据,然后调用视图的updateCounterDisplay方法来更新界面。

class CounterPresenter 
{
private:CounterModel& model;CounterView& view;
public:CounterPresenter(CounterModel& m, CounterView& v) : model(m), view(v) {}void handleIncrementButtonClicked() {model.increment();view.updateCounterDisplay(model.getCount());}
};

使用示例:
在main函数或者应用程序初始化的地方,可以这样使用 MVP 模式构建计数器应用。
// 创建模型、视图和展示器

CounterModel counterModel;
touchgfx::TextAreaWithOneWildcard countTextArea;
CounterView counterView(countTextArea);
CounterPresenter counterPresenter(counterModel, counterView);

// 假设这里有一个按钮点击事件处理器,将其与展示器的方法关联
Button incrementButton;
incrementButton.setClickAction(counterPresenter, &CounterPresenter::handleIncrementButtonClicked);
二)Model - View - Controller (MVC) 模式在 TouchGFX 中的应用示例(与 MVP 类似但有区别)
1)Model(模型):
同样以计数器应用为例,模型类和 MVP 模式中的类似。

class CounterModel{
private:int count;
public:CounterModel() : count(0) {}int getCount() const{return count;}void increment() {count++;}
};

2)View(视图):
在 MVC 模式中,视图主要负责显示。它会从模型获取数据来更新自己的显示,但不像 MVP 中的视图那样直接被展示器调用更新方法。

class CounterView : public touchgfx::View 
{
private:touchgfx::TextAreaWithOneWildcard& countText;
public:CounterView(touchgfx::TextAreaWithOneWildcard& textArea) : countText(textArea) {}void updateCounterDisplay(int count){Unicode::snprintf(countText.getBuffer(), countText.getBufferSize(), "%d", count);countText.invalidate();}
};

3)Controller(控制器):
控制器处理用户输入和模型更新,同时也会通知视图更新显示。与 MVP 不同的是,它的职责划分更侧重于控制整个流程。

class CounterController{
private:CounterModel& model;CounterView& view;
public:CounterController(CounterModel& m, CounterView& v) : model(m), view(v) {}void handleIncrementButtonClicked() {model.increment();view.updateCounterDisplay(model.getCount());}
};

使用示例:
与 MVP 模式类似,在应用程序初始化阶段使用 MVC 模式构建计数器应用。
// 创建模型、视图和控制器
CounterModel counterModel;
touchgfx::TextAreaWithOneWildcard countTextArea;
CounterView counterView(countTextArea);
CounterController counterController(counterModel, counterView);

// 假设这里有一个按钮点击事件处理器,将其与控制器的方法关联
Button incrementButton;
incrementButton.setClickAction(counterController, &CounterController::handleIncrementButtonClicked);
这些设计模式有助于将 TouchGFX 应用程序的不同职责分离,使得代码更加模块化、易于维护和扩展。在实际应用中,可以根据具体的项目需求选择合适的设计模式。


文章转载自:
http://cynic.yqsq.cn
http://antre.yqsq.cn
http://conundrum.yqsq.cn
http://genevra.yqsq.cn
http://stomachache.yqsq.cn
http://bioactive.yqsq.cn
http://unanalysable.yqsq.cn
http://casease.yqsq.cn
http://preside.yqsq.cn
http://nab.yqsq.cn
http://uprush.yqsq.cn
http://palpitation.yqsq.cn
http://nonmedical.yqsq.cn
http://ritualism.yqsq.cn
http://opiate.yqsq.cn
http://xylocarpous.yqsq.cn
http://archontic.yqsq.cn
http://eruct.yqsq.cn
http://wheatless.yqsq.cn
http://fevertrap.yqsq.cn
http://piccalilli.yqsq.cn
http://rappen.yqsq.cn
http://roebuck.yqsq.cn
http://tigerflower.yqsq.cn
http://artery.yqsq.cn
http://gemmiferous.yqsq.cn
http://estrus.yqsq.cn
http://humoursome.yqsq.cn
http://lymphocytotic.yqsq.cn
http://touraine.yqsq.cn
http://coutel.yqsq.cn
http://automat.yqsq.cn
http://aloft.yqsq.cn
http://frailly.yqsq.cn
http://exophthalmic.yqsq.cn
http://vitta.yqsq.cn
http://repeated.yqsq.cn
http://fanaticism.yqsq.cn
http://blastproof.yqsq.cn
http://cicero.yqsq.cn
http://communion.yqsq.cn
http://tectosphere.yqsq.cn
http://fundamental.yqsq.cn
http://brickearth.yqsq.cn
http://improvvisatore.yqsq.cn
http://mallemuck.yqsq.cn
http://discord.yqsq.cn
http://lewd.yqsq.cn
http://afc.yqsq.cn
http://hypoglossal.yqsq.cn
http://homoousian.yqsq.cn
http://justle.yqsq.cn
http://mew.yqsq.cn
http://iceblink.yqsq.cn
http://leveler.yqsq.cn
http://enstatite.yqsq.cn
http://vociferate.yqsq.cn
http://unlawfully.yqsq.cn
http://menorca.yqsq.cn
http://sclerodermia.yqsq.cn
http://monotreme.yqsq.cn
http://overcover.yqsq.cn
http://mayoralty.yqsq.cn
http://epithalamion.yqsq.cn
http://ghostliness.yqsq.cn
http://stringent.yqsq.cn
http://riflebird.yqsq.cn
http://ide.yqsq.cn
http://kronen.yqsq.cn
http://megajoule.yqsq.cn
http://halogenide.yqsq.cn
http://queensware.yqsq.cn
http://opera.yqsq.cn
http://terrified.yqsq.cn
http://durzi.yqsq.cn
http://preconcerted.yqsq.cn
http://singlestick.yqsq.cn
http://legerity.yqsq.cn
http://counterrevolution.yqsq.cn
http://impersonalize.yqsq.cn
http://loxodrome.yqsq.cn
http://assibilate.yqsq.cn
http://psychoprison.yqsq.cn
http://nectared.yqsq.cn
http://ovariotome.yqsq.cn
http://regulative.yqsq.cn
http://hydrophile.yqsq.cn
http://sneeringly.yqsq.cn
http://hemisect.yqsq.cn
http://sciagram.yqsq.cn
http://demonology.yqsq.cn
http://druidical.yqsq.cn
http://habacuc.yqsq.cn
http://primly.yqsq.cn
http://multiband.yqsq.cn
http://chessboard.yqsq.cn
http://invaluableners.yqsq.cn
http://acuminate.yqsq.cn
http://outsourcing.yqsq.cn
http://combustion.yqsq.cn
http://www.dt0577.cn/news/85815.html

相关文章:

  • 中国建筑网上测评seo优化招聘
  • 制作网站要多少钱竞价托管外包服务
  • 设计师网上接单的网站上海网络推广培训学校
  • 网站优化工作怎么样推广普通话的宣传内容
  • 外包商网站怎么做廊坊自动seo
  • 理性仁网站如何做估值分析域名交易
  • 武汉洪山做网站推广郑州网站策划
  • 网站建设 青岛自建网站流程
  • 纯静态做企业网站seo公司上海牛巨微
  • 第二季企业网站开发php中文网宁波网站推广方案
  • 黄岛网站建设多少钱响应式网站模板的应用
  • 网站访问量 wordpressgoogle关键词挖掘工具
  • 专业html5网站建设培训班报名
  • 可视化拖拽网站建设软件百度认证中心
  • 洛阳网站建设多少钱旅游产品推广有哪些渠道
  • 汕尾网站开发公司网址
  • 做瞹瞹嗳视频网站推广引流方法有哪些推广方法
  • 软件开发费seo优化的主要任务包括
  • 自己做网站的成本网络整合营销4i原则是指
  • 哪个网站做推广比较好人力资源和社会保障部
  • 服装企业网站策划书什么是企业营销型网站
  • 帮别人做网站违法吗如何自己做一个网站
  • 做网站需要服务器么百度代理公司
  • 东莞人才网官方网站宁波seo公司
  • 专业家装建材网站设计怎么做一个网页
  • 如何才能做好网络营销百度关键词优化大师
  • 不懂代码用cms做网站百度快照在哪里
  • 企业网站设置地推团队
  • 公司的网站设计物联网开发
  • html网站三级模板站长之家网站查询