Mosync:Widget 可以子类化 TimerListener 类吗
我知道 Moblet 对象可以子类化计时器侦听器类,但 Widget 也可以子类化 TimerListener 吗?
使用下面的代码,我收到错误在此范围内未声明“addTimer”:
class MyWidget : public QAButton, public TimerListener
// The class QAButton inherits from Label & PointerListener
{
MyWidget( MAUI::Widget *nParent, QAScreen *nDestinationScreen )
: Widget( 0, 0, 0, 0, nParent )
{
// Constructor:
}
void initAnimationTimer()
{
// Post:
addTimer( this, 20, 0 ); // Error here "`addTimer' was not declared in this scope"
}
void runTimerEvent()
{
// Post:
}
};
I know a Moblet object can subclass a timerlistener class but can a Widget also subclass the TimerListener?
With my code below I am getting an error `addTimer' was not declared in this scope:
class MyWidget : public QAButton, public TimerListener
// The class QAButton inherits from Label & PointerListener
{
MyWidget( MAUI::Widget *nParent, QAScreen *nDestinationScreen )
: Widget( 0, 0, 0, 0, nParent )
{
// Constructor:
}
void initAnimationTimer()
{
// Post:
addTimer( this, 20, 0 ); // Error here "`addTimer' was not declared in this scope"
}
void runTimerEvent()
{
// Post:
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TimerListener 是一个任何类都可以实现的接口(它具有纯虚函数 runTimerEvent)。
尝试访问 MyWidget 中的 addTimer 时会出现错误,因为它是 MAUtil::Environment 类的函数。您可以通过单例 MAUtil::Environment::getDefault() 访问它。
TimerListener is an interface (it has the pure virtual function runTimerEvent) which any class can implement.
You get an error when trying to access addTimer in MyWidget because it is a function of the MAUtil::Environment class. You can access it through the singleton MAUtil::Environment::getDefault().