【问题标题】:QwtPicker: disable movement of cursor via arrow keysQwtPicker:通过箭头键禁用光标移动
【发布时间】:2017-07-04 13:29:57
【问题描述】:

根据 QwtPicker 的Qwt documentation(它是我正在使用的类 QwtPlotZoomer 的超类),可以使用箭头键移动光标:

The cursor can be moved using the arrow keys

但是,我不想禁用它,因为箭头键在我的应用程序中有不同的用途。

这可以通过 API 实现吗?否则我需要继承我的 QwtPlotZoomer..

【问题讨论】:

    标签: c++ user-interface plot qwt


    【解决方案1】:

    好的,刚刚覆盖了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*){ }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2023-02-09
      • 2013-05-30
      相关资源
      最近更新 更多