QwtPicker:通过箭头键禁用光标移动
QwtPicker: disable movement of cursor via arrow keys
根据 QwtPicker 的 Qwt documentation(它是 QwtPlotZoomer 的超类,我正在使用 class),可以使用箭头键移动光标:
The cursor can be moved using the arrow keys
但是,我不想禁用它,因为箭头键在我的应用程序中有不同的用途。
这可以通过 API 实现吗?否则我需要 subclass 我的 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*){ }
};
根据 QwtPicker 的 Qwt documentation(它是 QwtPlotZoomer 的超类,我正在使用 class),可以使用箭头键移动光标:
The cursor can be moved using the arrow keys
但是,我不想禁用它,因为箭头键在我的应用程序中有不同的用途。
这可以通过 API 实现吗?否则我需要 subclass 我的 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*){ }
};