Results 1 to 2 of 2

Thread: qwt plots & inheritance

  1. #1
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qwt plots & inheritance

    well, I am doing something definitely wrong, but I can't find it..

    I followed the steps of "bode" example and created a class called my2dplot
    In the constructor of the class I implemented everything, like axis titles, how to get data, attach curves, etc.

    Qt Code:
    1. class my2dPlot : public QwtPlot
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. my2dPlot(QWidget *parent = 0);
    7. // int value() const;
    8. public Q_SLOTS:
    9. void setDamp(double damping);
    10. public slots:
    11. //general purpose functions
    12. void gridOn(); //sets the grid on-off
    13. double** getCurveData();//returns the data from file
    14.  
    15. //main spectroscopy curve functions
    16. void attachData2Curve(double**);//attach data to main curve
    17. void attachCurve2Plot();//attach main curve to plot widget
    18. void plotMainCurve(const QString &fileName );//function to call when you want to plot the main curve
    19. //it includes the call of the three previous functions
    20. //getCurveData, attachData2Curve, attachCurve2Plot
    21. int getDataSize(); //returns the size of the data
    22. void setDataSize(int);//sets the data size
    23.  
    24. //Continuum Curve functions
    25. void attachData2Continuum(double**);//attach data to Continuum curve
    26. void attachContinuum2Plot();//attach Continuum curve to plot widget
    27. void plotContinuumCurve(QString &fileName);//function to call when you want to plot the Continuum curve
    28.  
    29. //set the data file name to read
    30. void setDataFile (QString);
    31. //get the data file name to read
    32. QString getDataFile ();
    33. private slots:
    34.  
    35.  
    36. signals:
    37.  
    38. private:
    39. QwtPlot *myPlot;
    40. QwtPlotGrid *grid;
    41.  
    42. QwtPlotCurve *mainCurve;
    43. QwtPlotMarker *mainCurveMarker;
    44.  
    45. QwtPlotCurve *continuumCurve;
    46. QwtPlotMarker *continuumCurveMarker;
    47. QString dataFile;
    48. int dataSize;
    49.  
    50. };
    To copy to clipboard, switch view to plain text mode 

    Then I created a central widget including a member of my2dplot



    Qt Code:
    1. class my2dPlot;
    2. class QPolygon;
    3.  
    4.  
    5. class MyWidget : public QWidget
    6. {
    7. public:
    8. MyWidget(QWidget *parent = 0);
    9. my2dPlot *mainPlot;
    10.  
    11. protected:
    12.  
    13. private slots:
    14.  
    15. private Q_SLOTS:
    16. void moved(const QPoint &);
    17. void selected(const QPolygon &);
    18.  
    19. #ifndef QT_NO_PRINTER
    20. void print();
    21. #endif
    22. void exportDocument();
    23. void enableZoomMode(bool);
    24.  
    25. signals:
    26.  
    27.  
    28. private:
    29. //my2dPlot *mainPlot;
    30. QPushButton *quitButton;
    31.  
    32. void showInfo(QString text = QString::null);
    33. QwtPlotZoomer *d_zoomer[2];
    34. QwtPlotPicker *d_picker;
    35. QwtPlotPanner *d_panner;
    36. };
    To copy to clipboard, switch view to plain text mode 

    and then I set this widget as the mainWidget in the mainwindow.h

    The problem is that in the main window a plot area appears (with no background color-grey) and it does not show ANYTHING of what is described in the constructor of my2dclass. How is this possible? I mean, how is it possible that the widget creates a qwt plot (actually a my2dplot plot) and it does not take into consideration the rest of the my2dclass constructor?

    It must be something obvious, but I cannot really see it!
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qwt plots & inheritance

    what is the difference between:

    Qt Code:
    1. my2dPlot::my2dPlot(QWidget *parent)
    2. : QwtPlot(parent)
    3. {
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. my2dPlot::my2dPlot(QWidget *parent)
    2. : QWidget(parent)
    3. {
    To copy to clipboard, switch view to plain text mode 

    the first appears as the screenshot of the first post
    and the second appears as the screenshot f this post. It seems strange but there's something definitely wrong. The bode mouse tracker works only in grey area just above the green plot. The green plot is the one that is constructed in the my2dplot class. I can load a data file and see the plot, BUT I cannot use the zoomer of the bode example! Although I have declared:

    Qt Code:
    1. class MyWidget : public QWidget
    2. {
    3. public:
    4. MyWidget(QWidget *parent = 0);
    5. my2dPlot *mainPlot;
    To copy to clipboard, switch view to plain text mode 

    which means that mainPlot is a my2dPlot type and not just QwtPlot type. Somehow 2 different plot objects(my2dPlot,QwtPlot) are constructed at the same exactly position(see attachment)!
    Any ideas?!
    Attached Images Attached Images

Similar Threads

  1. Plots and Layouts
    By Ozzy in forum Qwt
    Replies: 5
    Last Post: 17th November 2009, 10:00
  2. Reg multiple plots in Qwt
    By Tavit in forum Qwt
    Replies: 4
    Last Post: 23rd June 2008, 14:43
  3. Lining up multiple plots
    By joel in forum Qwt
    Replies: 2
    Last Post: 20th June 2008, 01:25
  4. selecting text in Qwt plots
    By kaustav98255 in forum Qwt
    Replies: 3
    Last Post: 12th May 2008, 09:11
  5. Replies: 4
    Last Post: 25th October 2007, 13:23

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.