Results 1 to 2 of 2

Thread: recalculate lables in QwtScaleDraw

  1. #1
    Join Date
    Oct 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default recalculate lables in QwtScaleDraw

    hello.

    I have a source of data that is displayed in real time. the x-axis is current coordinate and it varies randomly (depending on the speed and direction). so for chart on the x-axis I'm using the current number of points, and replace it when displayed on the coordinate in QwtScaleDraw:
    Qt Code:
    1. // in QwtPlotCurve *pcd I fill data:
    2. for (int i = 0; (i < data.length); i++){
    3. xAlias[i] = i;
    4. x[i] = data_x[i];
    5. y[i] = data_y[i];
    6. }
    7. setSamples(xAlias, y, data.length);
    8.  
    9. // in QwtScaleDraw I take real value by alias:
    10. QwtText myQwtScaleDraw::label(double v) const
    11. {
    12. return QString("%1").arg(pcd->x[((int)v)]);
    13. }
    14.  
    15. // in main Widget:
    16. myPlot->setAxisScale(QwtPlot::xBottom, 0, data.length, 0);
    17. myPlot->replot();
    To copy to clipboard, switch view to plain text mode 

    but this only works if there is a change of xAlias[]. if I change the array x referenced by the xAlias, repainting occurs.
    how to make a graph to be redrawn manually?
    myPlot->repaint(), myPlot->update(), myPlot->axisWidget( QwtPlot::xBottom )->update(); does not work too.

    Thanks in advance.

  2. #2
    Join Date
    Oct 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: recalculate lables in QwtScaleDraw

    I found the solution:
    Qt Code:
    1. ((myQwtScaleDraw*)myPlot->axisScaleDraw(QwtPlot::xBottom))->invalidate(); // protected invalidateCache() inside;
    2. myPlot->update();
    3. myPlot->replot();
    To copy to clipboard, switch view to plain text mode 
    might be useful to someone

Similar Threads

  1. Problem with QwtScaleDraw
    By kanzaky in forum Qwt
    Replies: 3
    Last Post: 7th May 2013, 12:42
  2. LayoutDirectoin of QwtScaleDraw
    By jesse_mark in forum Qwt
    Replies: 1
    Last Post: 2nd November 2012, 07:31
  3. Refreshing a Custom QwtScaleDraw
    By grantbj74 in forum Qwt
    Replies: 6
    Last Post: 28th March 2012, 05:20
  4. Replies: 1
    Last Post: 13th October 2011, 16:52
  5. Replies: 1
    Last Post: 14th October 2010, 18:56

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.