Dear,

I am using a qwt plot and I want to update/or delete on a button click... problem is that i cannot delete the axis scales and when I create new it gets overwrite as shown in pic below.

Untitled.jpg

Qt Code:
  1. #include "subwindow_uwi.h"
  2. #include "ui_subwindow_uwi.h"
  3. #include <qwt_scale_draw.h>
  4. #include "dmg_eva.h"
  5. #include <QMessageBox>
  6. #include "plot_frm.h"
  7.  
  8.  
  9. class MyScaleDraw1: public QwtScaleDraw
  10. {
  11. public:
  12. MyScaleDraw1()
  13. {
  14. setTickLength( QwtScaleDiv::MajorTick, 10 );
  15. setTickLength( QwtScaleDiv::MinorTick, 2 );
  16. setTickLength( QwtScaleDiv::MediumTick, 0 );
  17.  
  18. setLabelRotation( 0 );
  19. setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
  20. setSpacing( 10 );
  21. }
  22.  
  23. virtual QwtText label( double value ) const
  24. {
  25. QwtText h=QwtText(QString::number((value*info_Inspection.scanInterval.toFloat())-(info_Inspection.Width.toInt()/2)));
  26. return h;
  27. }
  28. };
  29.  
  30. class MyScaleDraw2: public QwtScaleDraw
  31. {
  32. public:
  33. MyScaleDraw2()
  34. {
  35. setTickLength( QwtScaleDiv::MajorTick, 2 );
  36. setTickLength( QwtScaleDiv::MinorTick, 0 );
  37. setTickLength( QwtScaleDiv::MediumTick, 0 );
  38. setLabelRotation( 0 );
  39. setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
  40. setSpacing( 10 );
  41. }
  42.  
  43. virtual QwtText label( double value ) const
  44. {
  45. QwtText h=QwtText(QString::number((value*25/(info_FPGA.s_points/2))-12.5,'f',1));
  46. return h;
  47. }
  48. };
  49.  
  50. subwindow_uwi::subwindow_uwi(QWidget *parent) :
  51. QDialog(parent),
  52. ui(new Ui::subwindow_uwi)
  53. {
  54. ui->setupUi(this);
  55. }
  56.  
  57. subwindow_uwi::~subwindow_uwi()
  58. {
  59. delete ui;
  60. }
  61.  
  62. void subwindow_uwi::setframe()
  63. {
  64. d_plot_WavenumberSpectrum = new plot_frm( ui->WavenumberSpectrum );
  65. d_plot_WavenumberSpectrum->setGeometry(20,20,400,320);
  66. d_plot_WavenumberSpectrum->updateGeometry();
  67. d_plot_WavenumberSpectrum->updateAxes();
  68. d_plot_WavenumberSpectrum->setcolorbarmax(9);
  69. d_plot_WavenumberSpectrum->setAxisScaleDraw( QwtPlot::xBottom, new MyScaleDraw1() );
  70. d_plot_WavenumberSpectrum->setAxisScaleDraw( QwtPlot::yLeft, new MyScaleDraw2() );
  71. }
  72.  
  73. void subwindow_uwi::on_PB_delete()
  74. {
  75. delete d_plot_WavenumberSpectrum;
  76.  
  77. }
  78.  
  79. void subwindow_uwi::on_PB_WavenumberSpectrum_clicked()
  80. {
  81.  
  82. if(run_wavenumber_vs_frequency_read() != SIPIF_ERR_OK )
  83. { msgb.setText("Cannot read"); msgb.exec();
  84. }
  85.  
  86. setframe();
  87.  
  88. }
To copy to clipboard, switch view to plain text mode 

Best Regards,

HAIDER