基于上一个博客的案例测试
研究问题:
#ifndef FRONTENDAPPLICATION_HPP
#define FRONTENDAPPLICATION_HPP
#include <gui_generated/common/FrontendApplicationBase.hpp>
class FrontendHeap;
using namespace touchgfx;
class FrontendApplication : public FrontendApplicationBase
{
public:
FrontendApplication(Model& m, FrontendHeap& heap);
virtual ~FrontendApplication() { }
virtual void handleTickEvent()
{
model.tick();
FrontendApplicationBase::handleTickEvent();
}
private:
};
#endif // FRONTENDAPPLICATION_HPP
他这里 handleTickEvent 完成重写 同时调用了基类的 handleTickEvent
自己测试一下:
《图片》
#include <iostream>
using namespace std;
class People {
public:
void eat() {
get_util_to_eat();
}
virtual void get_util_to_eat() {
std::cout << "People get chopsticks" << std::endl;
}
};
class Children : public People {
public:
virtual void get_util_to_eat() {
std::cout << "Children get scoop" << std::endl;
People::get_util_to_eat();
//People::eat();
}
};
int main() {
People* people = new Children();
people->eat();
return 0;
}
/*
Children get scoop
People get chopsticks
如果修改为People::eat();那就是无限死循环死机的!
所以我的是同名的!
*/
继续研究一遍 他是子类覆盖父类的(用的多画面工程 时钟的那个)
C:\TouchGFXProjects\MyApplication1\touchgfx\framework\include\touchgfx
Screen.hpp
这是一个最基础的类
有 virtual void handleTickEvent()
{
printf("A");
}
随后
醉了末班 View
template<class T>
class View : public Screen
{
public:
也就是V不是基类 而是魔板!!
再开始只读的基类
class Screen2ViewBase : public touchgfx::View<Screen2Presenter>
{
public:
所以 Screen2ViewBase 是有 handleTickEvent 的
只不过他灭有写
继续派生 终于有了
class Screen2View : public Screen2ViewBase
{
public:
virtual void handleTickEvent() ;
可以看到 Screen2View 里面的 handleTickEvent 执行 会覆盖原来的 virtual void handleTickEvent()
{
printf("A");
}
其实你可以测试 在画面1也这样做:
class Screen1View : public Screen1ViewBase
{
public:
Screen1View();
virtual void handleTickEvent();
void Screen1View::handleTickEvent()
{
printf("B");
}
终于就不会输出A 而是B了
和UIKIT对比:
只能看到用的 地方 就是
virtual void handleTickEvent()
{
model.tick();
FrontendApplicationBase::handleTickEvent();// virtual void handleTickEvent() { }
}
在哪里调用的 你是不知道的 据说是1S执行60次 是LCD屏幕的TE中断 周期性触发的
一旦屏幕没有点亮 也就不会周期调用了
也就是这里的 model.tick();==uikit的 notify