Results 1 to 5 of 5

Thread: QwtPlotCurve: how to delete/erase/empty the Data?

  1. #1
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QwtPlotCurve: how to delete/erase/empty the Data?

    Hello,
    is there any possibility to clear the Data in a QwtPlotCurve object?

    like: QwtPlotCurve MyCurve; MyCurve.clear(); or MyCurve.data.clear();
    I've seen QwtPlot has a clear() function available.
    I have "QwtPlotCurve MyCurve" objects living in mainwindow.cpp all the time. The only way to delete the Objects is with delete MyCurve and Creating it again with the new operator.

    But i need the QwtPlotCurve- objects to be alive, the whole time.
    In the case i have to implement this by myself, the Data in QwtPlotCurve is private... so i cannot inherit it?
    thanks Astronomy

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

    Default Re: QwtPlotCurve: how to delete/erase/empty the Data?

    curve->setData(QwtArray<QwtDoublePoint>());

    Uwe

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

    Astronomy (15th January 2010)

  4. #3
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotCurve: how to delete/erase/empty the Data?

    Hi Uwe,
    thanx for the reply.

    that 's actually what i'm doing now. But with a QVector<double> Data and; curve->setData( Data1 ); and overwriting it with new Data..

    The Question is:
    1) If Data1 has 100 Entries and Data2 has less entries, eg. Data2[20] ; curve->setData( Data2 ) what does happen? Are the last 80 Entries the Old Data?

    2) Or is the Memory, which was first located for 100 Entries now freed? Or are 80 Entries reserved with 0.0
    ( I have really big Data...) i'm going to debug 1) + 2)..

    3) If you suggest with curve->setData(QwtArray<QwtDoublePoint>());, a simple overwrite, i have to overwerite the whole size of the Array with "0.0" for doing the clear() job?

    Background:
    I'm using CZoomer for zooming and i'm loading several Data1,2,3,.... in QwtPlot MyPlot two QwtPlotCurve MyCurve1 and QwtPlotCurve MyCurve2.
    And for unknown reasons the Data i've erased from MyCurve, is sudden visible again if i zoom out? Maybe it's an CZoomer problem, but i was thinking, that it is because of QwtPlotCurve has no nice clear() Funktion?


    greetings Astronomy
    Last edited by Astronomy; 15th January 2010 at 16:43.

  5. #4
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotCurve: how to delete/erase/empty the Data?

    Ah i just found out:
    So SetData does make a total clearance if new data is inserted.

    void QwtPlotCurve::setData(const QPolygonF &data)
    #endif
    {
    delete d_xy;
    d_xy = new QwtPolygonFData(data);
    itemChanged();
    }

    or

    void QwtPlotCurve::setData(const QwtData &data)
    {
    delete d_xy;
    d_xy = data.copy();
    itemChanged();
    }

  6. #5
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotCurve: how to delete/erase/empty the Data?

    Thanks to Uwe the trick with: curve->setData(QwtArray<QwtDoublePoint>());
    worked.

    I do not quite understand why ::setData(const QPolygonF &data) needs a new operator in the implementation and ::setData(const QwtData &data) below not. As i know, after each delete must follow a new operator? But as long as it works it should not bother me (-;

    regards A.

Similar Threads

  1. Empty SQL Data from ODBC/FreeTDS
    By dentharg in forum Qt Programming
    Replies: 0
    Last Post: 9th November 2009, 07:50
  2. Erase menubar
    By lixo1 in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2009, 16:04
  3. Replies: 2
    Last Post: 18th December 2008, 07:43
  4. help using QLists as data in QwtPlotCurve
    By esorensen in forum Qwt
    Replies: 1
    Last Post: 11th July 2008, 19:52
  5. remove directory empty or not empty
    By raphaelf in forum Newbie
    Replies: 12
    Last Post: 27th October 2006, 07:30

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.