Results 1 to 5 of 5

Thread: Ignoring keyboard events in QwtPlotPicker

  1. #1
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Ignoring keyboard events in QwtPlotPicker

    Sorry if this question was already asked, I couldn't find it searching.

    I have the following plot picker initialized for my QwtPlot:
    Qt Code:
    1. mPicker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    2. QwtPlotPicker::CrossRubberBand, QwtPlotPicker::AlwaysOff, canvas());
    3. mPicker->setStateMachine(new QwtPickerClickPointMachine());
    To copy to clipboard, switch view to plain text mode 

    I see that the default behavior is that the keyboard events (mainly the direction keys) are handled by the plot picker to move around the cross. How can I ignore these events so that they are not caught by the plot / picker?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Ignoring keyboard events in QwtPlotPicker

    QwtPicker is derived from QwtEventPattern, where all mouse and keyboard assignments are defined, that the picker handles.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    frankiefrank (22nd January 2012)

  4. #3
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Ignoring keyboard events in QwtPlotPicker

    Thanks for your reply Uwe. I see the inheritance and I see some samples that define mouse keys. But what I still can't understand is how to set my object to ignore the up and down keys.

    I'm looking at the documentation at http://qwt.sourceforge.net/class_qwt_event_pattern.html but I don't see the right way to go.

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Ignoring keyboard events in QwtPlotPicker

    Simply change the key code, that is connected to the KeyUp/KeyDown events. 0 would disable the functionality completely ( as it is no valid key code ).

    Qt Code:
    1. mPicker->setKeyPattern( QwtEventPattern::KeyUp, ... );
    2. mPicker->setKeyPattern( QwtEventPattern::KeyDown, ... );
    To copy to clipboard, switch view to plain text mode 
    Check QKeyEvent for the meaning of the key/button combinations you could use to redefine your picker.

    Uwe

  6. The following user says thank you to Uwe for this useful post:

    frankiefrank (23rd January 2012)

  7. #5
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Ignoring keyboard events in QwtPlotPicker

    Thank you! That was exactly what I was looking for.

Similar Threads

  1. Can I use delegate to catch mouse and keyboard events
    By hubbobubbo in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2010, 12:00
  2. Filtering all mouse/keyboard events
    By maverick_pol in forum Qt Programming
    Replies: 9
    Last Post: 27th November 2008, 17:03
  3. Grab keyboard events in Windows
    By durbrak in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2007, 19:56
  4. Qtoolbutton-ignoring mouse events
    By rvenugopal in forum Qt Programming
    Replies: 2
    Last Post: 26th December 2006, 22:12
  5. handling keyboard events from a console app
    By g.cavallin in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2006, 22:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.