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
    0_1475731899218_Untitled.jpg
    I also have a delete button. and I first call on_PB_delete_clicked() and then on_PB_WavenumberSpectrum_clicked()

    #include "subwindow_uwi.h"
    #include "ui_subwindow_uwi.h"
    #include <qwt_scale_draw.h>
    #include "dmg_eva.h"
    #include <QMessageBox>
    #include "plot_frm.h"
     
     
    class MyScaleDraw1: public QwtScaleDraw
    {
    public:
        MyScaleDraw1()
        {
            setTickLength( QwtScaleDiv::MajorTick, 10 );
            setTickLength( QwtScaleDiv::MinorTick, 2 );
            setTickLength( QwtScaleDiv::MediumTick, 0 );
     
            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;
        }
    };
     
    class MyScaleDraw2: public QwtScaleDraw
    {
    public:
        MyScaleDraw2()
        {
            setTickLength( QwtScaleDiv::MajorTick, 2 );
            setTickLength( QwtScaleDiv::MinorTick, 0 );
            setTickLength( QwtScaleDiv::MediumTick, 0 );
            setLabelRotation( 0 );
            setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
            setSpacing( 10 );
        }
     
        virtual QwtText label( double value ) const
        {
            QwtText h=QwtText(QString::number((value*25/(info_FPGA.s_points/2))-12.5,'f',1));
            return h;
        }
    };
     
    subwindow_uwi::subwindow_uwi(QWidget *parent) :
        QDialog(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_clicked()
    {
        delete d_plot_WavenumberSpectrum;
     
    }
     
    void subwindow_uwi::on_PB_WavenumberSpectrum_clicked()
    {
        QMessageBox msgb;
     
        if(run_wavenumber_vs_frequency_read() != SIPIF_ERR_OK )
        {  msgb.setText("Cannot read");   msgb.exec();
        }
     
        setframe();
     
    }
    

  • Qt Champions 2017

    Hi,
    Please upload the image to an external site (e.g. postimage.org) and link it here with the appropriate tag: ![](image url).
    The forum's upload feature isn't working properly, so we can't see the picture.



  • https://postimg.org/image/cttygz5nd/

    Edit: Fixed link to image -- @Wieland


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.