Virtual function
Mainly to polymorphism. Under normal circumstances, the parent class member functions can not be called a subclass, but once the subclass function is virtual function, then the parent can call the function. Case are as follows:
Parent *p = new Children();
//调用 Parent 类中的 method() 方法
p->method();
//调用 Children 类中的 virtualMethod() 方法
p->virtualMethod();
Qt using Virtual Function
Mainly differ in states:
protected:
/**
* Q_DECL_OVERRIDE:这个宏表示修饰的函数是对父类虚函数的重载
*/
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;