Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Problem with qwtplot update/ destruction
QtWS25 Last Chance

Problem with qwtplot update/ destruction

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
qwt
3 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    habbas33
    wrote on 6 Oct 2016, 05:31 last edited by A Former User 10 Aug 2016, 16:25
    #1

    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();
     
    }
    
    K 1 Reply Last reply 6 Oct 2016, 05:53
    0
    • H habbas33
      6 Oct 2016, 05:31

      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();
       
      }
      
      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 6 Oct 2016, 05:53 last edited by
      #2

      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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        habbas33
        wrote on 6 Oct 2016, 06:54 last edited by A Former User 10 Aug 2016, 16:24
        #3

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

        Edit: Fixed link to image -- @Wieland

        1 Reply Last reply
        0

        2/3

        6 Oct 2016, 05:53

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved