QT中原本的控件不能满足需求需要自定义控件然后将原控件提升为自定义控件。
QT中原本QgraphicsView类不具备鼠标及按键的事件捕捉功能,所以需要对该类进行继承,然后添加鼠标响应事件。
1. 新建一个普通的类CustomQGraphicsView
class CustomQGraphicsView :
{
public:
CustomQGraphicsView();
};
2. 继承父类QGraphicsView。
3.添加Q_OBJECT
QT中原本的控件不能满足需求需要自定义控件然后将原控件提升为自定义控件。
QT中原本QgraphicsView类不具备鼠标及按键的事件捕捉功能,所以需要对该类进行继承,然后添加鼠标响应事件。
1. 新建一个普通的类CustomQGraphicsView
class CustomQGraphicsView :
{
public:
CustomQGraphicsView();
};
2. 继承父类QGraphicsView。
3.添加Q_OBJECT