Results 1 to 7 of 7

Thread: How to add Button on Legend to enable/disable QwtPlotZoomer ?

  1. #1
    Join Date
    Jun 2015
    Posts
    71
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to add Button on Legend to enable/disable QwtPlotZoomer ?

    Hi Everyone,

    I have working on graph, where I have using 2 vertical and 2 horizontal lines(Draggable and droppable along the graph).
    Not if I enable QwtPlotZoomer then while dragging Lines on the graph QwtPlotZoomer takes control, so on that node dragging and zooming both comes into effect.
    Here I want a small button or something on the Legend which help me to enable or disable QwtPlotZoomer, so that on dragging lines zooming should not work and vice versa.

    Thanks

  2. #2
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    76
    Thanks
    9
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to add Button on Legend to enable/disable QwtPlotZoomer ?

    Hi ??? [npatil15],

    there's an easy way to avoid zooming while dragging - define an additional keyboard modifier to distinguish between dragging or zooming.

    If you really want a button, simply create a new curve, make the line attribute NoLine and make the legend button reacting on mouse clicks (see explanation in QwtBook https://ghorwin.github.io/qwtbook/in...isse-reagieren)

    Bye,
    Andreas
    Andreas

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

    npatil15 (17th January 2019)

  4. #3
    Join Date
    Jun 2015
    Posts
    71
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add Button on Legend to enable/disable QwtPlotZoomer ?

    Thanks ghorwin,

    Yes by setting additional keyword will help but that's not the task.
    And the link/knowledge you share it surely help me for my next task. But now I have some different pain.

    Here I'm unable to add any linked instance, button or something like below code for QwtPlotZoomer, where I can click and do something for this clicked event.
    (say setItemAttribute(QwtPlotItem::Legend, true);)

  5. #4
    Join Date
    Jun 2015
    Posts
    71
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add Button on Legend to enable/disable QwtPlotZoomer ?

    Please anyone has any solution or suggestions over it ?

  6. #5
    Join Date
    Jun 2015
    Posts
    71
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add Button on Legend to enable/disable QwtPlotZoomer ?

    Hi ghorwin,

    Can you just tell me how I can use ctrl to switch between zoom and dragging option ?
    I don't understand properly how to use setMousePattern to enable plot zoomer.

    Thanks


    Added after 1 6 minutes:


    I have done this, just for the reference I'll mention it here,
    Qt Code:
    1. m_zoomer = new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, m_plot->canvas());
    2. m_zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton, Qt::ControlModifier);
    To copy to clipboard, switch view to plain text mode 

    Last edited by npatil15; 22nd January 2019 at 10:42.

  7. #6
    Join Date
    Jun 2015
    Posts
    71
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add Button on Legend to enable/disable QwtPlotZoomer ?

    Hi,

    I'm facing issue regarding the same again,
    I still need PushButton on legend, and other marker should not override on it.

    I have done line this below,
    Qt Code:
    1. QPushButton *detachLegendButton = new QPushButton("Toggle attached", m_legend->contentsWidget());
    To copy to clipboard, switch view to plain text mode 

    But here this button is come over one of the QwtPlotMarker.

    Please suggest, how I can do that ?

  8. #7
    Join Date
    Jun 2015
    Posts
    71
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add Button on Legend to enable/disable QwtPlotZoomer ?

    I have done it,
    Answer is mention at the end of this post
    https://www.qtcentre.org/threads/699...fier)?p=304315


Similar Threads

  1. Replies: 2
    Last Post: 12th May 2015, 10:19
  2. Enable and Disable Close (X)
    By anh5kor in forum Newbie
    Replies: 2
    Last Post: 25th March 2015, 06:45
  3. Replies: 4
    Last Post: 14th February 2014, 17:57
  4. disable enable network connections?
    By remy06 in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2009, 17:52
  5. disable/enable shortcut
    By harakiri in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2007, 10:58

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.