Results 1 to 2 of 2

Thread: Markers are not removed from QwtPlot

  1. #1
    Join Date
    May 2010
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Markers are not removed from QwtPlot

    Hello,
    I'm writing an application that uses Qwt 5.2.1 and uses QwtPlot in a QGraphicsView widget. I have a QwtPlotCurve and 1 or two QwtPlotMarker as horizontal lines. I'm trying to add vertical markers as an array of QwtPlotMarker. The first time I add them it works OK:
    1..jpg
    When I select new points for the markers, I would like remove the old ones but they remain on the plot:
    2..jpg
    here is the code:
    //////// Draw Vertical Markers
    void ThresholdDataPlot:rawXMarkers(QList<double> *l)
    {
    double y;
    MarkersX = l;
    nXMarkers = MarkersX->count();
    VMarks = new QwtPlotMarker *[nXMarkers];

    QPen p(Qt::blue);

    for(int i = 0; i < nXMarkers; i++)
    {
    VMarks[i] = new QwtPlotMarker();
    VMarks[i]->setLinePen(p);
    VMarks[i]->setLineStyle(QwtPlotMarker::VLine);
    y = MarkersX->at(i);
    VMarks[i]->setXValue(y);
    VMarks[i]->attach(this);
    }

    replot();
    }


    void ThresholdDataPlot::CleanXMarkers()
    {
    if(VMarks == NULL) return;

    for(int i = 0; i < nXMarkers; i++)
    {
    VMarks[i]->hide();
    VMarks[i]->detach();
    delete VMarks[i];
    }
    delete [] VMarks;

    VMarks = NULL;
    replot();
    }

    Any ideas?

    Thanks,

    Muz

  2. #2
    Join Date
    Oct 2009
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Markers are not removed from QwtPlot

    Hello.

    I've one example in which there is one checkbox that shows the markers if you check it and hide them if you uncheck it. The function i have is the next:

    Qt Code:
    1. void CWGraficaSimple::on_chkMostrarEventos_stateChanged(int state)
    2. {
    3.  
    4. QVectorIterator<QwtPlotMarker*> itMarcas(vMarcas);
    5.  
    6. while(itMarcas.hasNext())
    7. itMarcas.next()->setVisible(state);
    8. qwtPlot->replot();
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    Maybe if you first set the visible estate to false and then you delete it, it will work.

    I hope that helps.
    Regards

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

    MuzZviman (11th June 2010)

Similar Threads

  1. Help: How to draw markers on plot?
    By jwieland in forum Qwt
    Replies: 5
    Last Post: 24th November 2009, 11:22
  2. Replies: 2
    Last Post: 27th October 2009, 13:40
  3. How to restore removed widget from QMdiArea ?
    By remdex in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2009, 19:59
  4. qscintilla and markers
    By sawerset in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2009, 21:39
  5. viewing removed but not submitted rows
    By maxel in forum Qt Programming
    Replies: 6
    Last Post: 6th October 2006, 17:20

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.