Results 1 to 3 of 3

Thread: Problem with qwtplot update/ destruction

  1. #1
    Join Date
    Sep 2014
    Posts
    10
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

    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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,243
    Thanks
    303
    Thanked 866 Times in 853 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Sep 2014
    Posts
    10
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with qwtplot update/ destruction

    I also have a delete button. and I first delete before making new one

Similar Threads

  1. Replies: 2
    Last Post: 31st March 2016, 23:35
  2. How QDeclarativeView destruction
    By xman_ss in forum Qt Programming
    Replies: 3
    Last Post: 27th April 2012, 08:55
  3. Replies: 1
    Last Post: 1st February 2010, 16:13
  4. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 11:31
  5. What happens after closing and before destruction?
    By Raccoon29 in forum Qt Programming
    Replies: 45
    Last Post: 20th May 2008, 10:33

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.