所需待重写函数:
[virtual] bool QObject::eventFilter(QObject *watched, QEvent *event);
/*
* Filters events if this object has been installed as an event filter for the watched object.
* In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
*/
以上来自官方辅助手册
说明:
通过事宜过滤器,即上述重写函数,可通过条件,筛选所需事宜
若是筛选乐成,若是此事宜后续不再使用,返回true,后续若是再次使用,返回false
若是筛选不乐成,则返回给父类,防止父类处于内部目的重新实现了 eventFilter()
代码示例:
MainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
#include
#define STANDFLDCOL0
#define LAYERFLDCOL1
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{