在程序中直接重新定义QWidget类的customEvent函数编译通过,如下定义,
void QWidget::customEvent(QCustomEvent *e) //用户自定义事件处理函数
{
if (e->type()==60000)
{
UserEvent *re = (UserEvent *) e;
newstring = re->str();
}
}
但是没有事件处理。
在QWidget类的子类ChildWidget中定义customEvent函数如:
void ChildWidget::customEvent(QCustomEvent *e) //用户自定义事件处理函数
{
if (e->type()==60000)
{
UserEvent *re = (UserEvent *) e;
newstring = re->str();
}
}
会提示ChildWidget类中没有customEvent函数,因为ChildWidget子类已经继承了QWidget类 为什么不能在子类中重定义customEvent函数呢?