2017-07-04 116 views
0

禁用光標的移動根據QwtPicker(這是QwtPlotZoomer的superclas,我使用的類)的光標的Qwt documentation可以用箭頭鍵來移動:QwtPicker:通過箭頭鍵

The cursor can be moved using the arrow keys 

但是,我不想禁用它,因爲在我的應用程序中箭頭鍵具有不同的用途。

這是可能通過API嗎?否則,我需要繼承我的QwtPlotZoomer ..

回答

0

好吧,剛剛結束覆蓋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*){ } 
};