Results 1 to 4 of 4

Thread: What is the elegant way to disable picker/zoomer when the plot is disabled?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2012
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb What is the elegant way to disable picker/zoomer when the plot is disabled?

    I found that when the plot is disabled (by setEnabled(false) of plot's parent's parent), the picker and zoomer still works.
    What is the elegant way to disable picker&zoomer when the plot is disabled?


  2. #2
    Join Date
    Dec 2013
    Location
    Toronto, Canada
    Posts
    62
    Thanked 16 Times in 15 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: What is the elegant way to disable picker/zoomer when the plot is disabled?

    I would subclass QwtPlot and reimplement changeEvent()
    ...
    see code

    Qt Code:
    1. #include <QApplication>
    2. #include <qwt_plot.h>
    3. #include <qwt_plot_zoomer.h>
    4. #include <QEvent>
    5.  
    6. class Plot: public QwtPlot
    7. {
    8. public:
    9. Plot(QWidget* parent=0):QwtPlot(parent)
    10. {
    11. _zoomer = new QwtPlotZoomer(this->canvas());
    12. }
    13. protected:
    14. void changeEvent(QEvent * event)
    15. {
    16. if(event->type()==QEvent::EnabledChange)
    17. {
    18. _zoomer->setEnabled(this->isEnabled());
    19. }
    20. }
    21. private:
    22. QwtPlotZoomer* _zoomer;
    23. };
    24.  
    25. int main(int argc, char *argv[])
    26. {
    27. QApplication a(argc, argv);
    28. QwtPlot* plot = new Plot;
    29.  
    30. plot->setEnabled(false);
    31.  
    32. plot->show();
    33.  
    34. return a.exec();
    35. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2012
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the elegant way to disable picker/zoomer when the plot is disabled?

    Thanks your share.
    Because the zoomer/picker is not always enabled in my case,
    I must remember the picker/zoomer's state (named oldState) before the plot changes to disabled. Then the plot is enabled, the zoomer should be set to the oldState.

Similar Threads

  1. Qwt Plot Picker as position indicator
    By Kutuska in forum Qwt
    Replies: 1
    Last Post: 7th September 2012, 14:01
  2. Disable the QToolBar when the QMenuBar gets disabled?
    By dobedidoo in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2010, 13:51
  3. Replies: 1
    Last Post: 24th February 2009, 18:35
  4. Plot Picker x=0
    By sun in forum Qwt
    Replies: 2
    Last Post: 7th October 2008, 07:43
  5. Replies: 0
    Last Post: 27th May 2008, 01:00

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.