2011-03-16 87 views
0

我知道Moblet對象可以繼承一個timerlistener類,但是Widget是否也可以繼承TimerListener的子類?Mosync: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: 

    } 
}; 

回答

0

TimerListener是一個接口(它具有純虛函數runTimerEvent)的任何類都可以實行。

當您嘗試訪問MyWidget中的addTimer時會出錯,因爲它是MAUtil :: Environment類的函數。您可以通過單例MAUtil :: Environment :: getDefault()來訪問它。