QwtPicker:通过箭头键
问题描述:
禁用光标的移动根据QwtPicker(这是QwtPlotZoomer的superclas,我使用的类)的光标的Qwt documentation可以用箭头键来移动:QwtPicker:通过箭头键
The cursor can be moved using the arrow keys
但是,我不想禁用它,因为在我的应用程序中箭头键具有不同的用途。
这是可能通过API吗?否则,我需要继承我的QwtPlotZoomer ..
答
好吧,刚刚结束覆盖QwtPicker的相关功能,这工作正常。
class MyQwtPlotZoomer : public QwtPlotZoomer
{
public:
MyQwtPlotZoomer(int xAxis, int yAxis, QwtPlotCanvas* canvas, bool doReplot = true) : QwtPlotZoomer(xAxis, yAxis, canvas, doReplot){ }
virtual ~MyQwtPlotZoomer(){ }
protected:
virtual void widgetKeyPressEvent(QKeyEvent* ke)
{
if (!isActive())
{
if (keyMatch(KeyUndo, ke))
zoom(-1);
else if (keyMatch(KeyRedo, ke))
zoom(+1);
else if (keyMatch(KeyHome, ke))
zoom(0);
}
}
virtual void widgetKeyReleaseEvent(QKeyEvent*){ }
};