1 Attachment(s)
Problem with qwtplot update/ destruction
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.
Attachment 12141
Code:
#include "subwindow_uwi.h"
#include "ui_subwindow_uwi.h"
#include <qwt_scale_draw.h>
#include "dmg_eva.h"
#include <QMessageBox>
#include "plot_frm.h"
{
public:
MyScaleDraw1()
{
setLabelRotation( 0 );
setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
setSpacing( 10 );
}
virtual QwtText label
( double value
) const {
QwtText h
=QwtText(QString::number((value
*info_Inspection.
scanInterval.
toFloat())-(info_Inspection.
Width.
toInt()/2)));
return h;
}
};
{
public:
MyScaleDraw2()
{
setLabelRotation( 0 );
setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
setSpacing( 10 );
}
virtual QwtText label
( double value
) const {
return h;
}
};
subwindow_uwi
::subwindow_uwi(QWidget *parent
) : ui(new Ui::subwindow_uwi)
{
ui->setupUi(this);
}
subwindow_uwi::~subwindow_uwi()
{
delete ui;
}
void subwindow_uwi::setframe()
{
d_plot_WavenumberSpectrum = new plot_frm( ui->WavenumberSpectrum );
d_plot_WavenumberSpectrum->setGeometry(20,20,400,320);
d_plot_WavenumberSpectrum->updateGeometry();
d_plot_WavenumberSpectrum->updateAxes();
d_plot_WavenumberSpectrum->setcolorbarmax(9);
d_plot_WavenumberSpectrum
->setAxisScaleDraw
( QwtPlot::xBottom,
new MyScaleDraw1
() );
d_plot_WavenumberSpectrum
->setAxisScaleDraw
( QwtPlot::yLeft,
new MyScaleDraw2
() );
}
void subwindow_uwi::on_PB_delete()
{
delete d_plot_WavenumberSpectrum;
}
void subwindow_uwi::on_PB_WavenumberSpectrum_clicked()
{
if(run_wavenumber_vs_frequency_read() != SIPIF_ERR_OK )
{ msgb.setText("Cannot read"); msgb.exec();
}
setframe();
}
Best Regards,
HAIDER
Re: Problem with qwtplot update/ destruction
In line 79, you call setFrame() (which creates a new d_plot_WavenumberSpectrum), but you do not delete the old one. So you probably have two plots on top of each other and that is why it looks like there are two sets of axes. I think there are actually two complete plots, but because the center part is a spectrogram one of these covers up the other.
Re: Problem with qwtplot update/ destruction
I also have a delete button. and I first delete before making new one