Results 1 to 3 of 3

Thread: zooming with ctrl + mouse wheel

  1. #1
    Join Date
    Jan 2014
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy zooming with ctrl + mouse wheel

    My problem is very interesting to me. I am working on Qwt and I would like to enable zoom respect X and Y axis separately. I achived zoom only X axis but Y axis didn't work. I couldn't get it. I will be glad if you give an advise.

    Here is my code:
    Qt Code:
    1. void Kmh::keyPressEvent(QKeyEvent *event)
    2. {
    3. zoom_in_out = new QwtPlotMagnifier( canvas() );
    4.  
    5. if(event->key() == Qt::Key_Shift)
    6. {
    7. zoom_in_out->setWheelModifiers(Qt::ShiftModifier);
    8. zoom_in_out->setAxisEnabled(Qt::XAxis,false);
    9. }
    10. else if(event->key() == Qt::Key_Control)
    11. {
    12. zoom_in_out->setWheelModifiers(Qt::ControlModifier);
    13. zoom_in_out->setAxisEnabled(Qt::YAxis,false);
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 
    shift + mousewheel is working for zoom respect X axis. But ctrl + mousewheel is zooming both X and Y axis. What am I doing wrong?

    Regards
    Last edited by alperyazir66; 2nd January 2014 at 12:33. Reason: spelling corrections

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

    Default Re: zooming with ctrl + mouse wheel

    Do something like this:

    Qt Code:
    1. class YourPlot: public QwtPlot
    2. {
    3. public:
    4. YourPlot( QWidget *parent ):
    5. QwtPlot( parent )
    6. {
    7. QwtPlotMagnifier *magnifier1 = new QwtPlotMagnifier( canvas() );
    8. magnifier1->setMouseButton(... );
    9. magnifier1->setAxisEnabled( QwtPlot::yLeft, false );
    10.  
    11. QwtPlotMagnifier *magnifier2 = new QwtPlotMagnifier( canvas() );
    12. magnifier2->setMouseButton(... );
    13. magnifier2->setAxisEnabled( QwtPlot::xBottom, false );
    14.  
    15. ...
    16. }
    17. };
    To copy to clipboard, switch view to plain text mode 
    HTH,
    Uwe

  3. #3
    Join Date
    May 2015
    Posts
    1
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: zooming with ctrl + mouse wheel

    all this time had problems till i found this. thanks

Similar Threads

  1. QPrintPreviewWidget mouse wheel events
    By ChrisW67 in forum Qt Programming
    Replies: 3
    Last Post: 26th October 2013, 06:32
  2. Replies: 0
    Last Post: 16th July 2012, 09:56
  3. Replies: 0
    Last Post: 6th March 2012, 10:56
  4. Can usb mouse wheel work in Qt/E ?
    By earth in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th August 2011, 11:00
  5. Scrolling on Mouse Wheel
    By penny in forum Qt Programming
    Replies: 4
    Last Post: 7th April 2011, 07:30

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.