Results 1 to 2 of 2

Thread: QFrame error when subclassing QwtPlot

  1. #1
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default QFrame error when subclassing QwtPlot

    Hi,

    I was making a simple subclass of QwtPlot but Iḿ ot able to compile it. Every time I try, I get this error:

    In file included from vectplot.h:2,
    from principal.h:10,
    from principal.cpp:1:
    /usr/include/qt4/QtGui/qframe.h: In copy constructor ‘QwtPlot::QwtPlot(const QwtPlot&)’:
    /usr/include/qt4/QtGui/qframe.h:140: error: ‘QFrame::QFrame(const QFrame&)’ is private
    /usr/local/qwt-5.2.0/include/qwt_plot.h:73: error: within this context
    Here's the code from my vectplot.h file:

    Qt Code:
    1. #include <qwt_plot.h>
    2.  
    3.  
    4. class Vectplot: public QwtPlot
    5. {
    6. Q_OBJECT
    7.  
    8. public:
    9. Vectplot(QWidget *parent = NULL);
    10.  
    11. private:
    12. void alignScales();
    13. void getDataPlot();
    14. double equis[2000];
    15. double ye1[2000];
    16. double ye2[2000];
    17. };
    To copy to clipboard, switch view to plain text mode 

    And here's the code from the vectplot.cpp file:

    Qt Code:
    1. #include "vectplot.h"
    2. #include <math.h>
    3. #include <qpainter.h>
    4. #include <qwt_plot_curve.h>
    5. #include <qwt_symbol.h>
    6. #include <qwt_scale_widget.h>
    7. #include <stdlib.h>
    8.  
    9.  
    10. Vectplot::Vectplot(QWidget *parent):
    11. QwtPlot(parent)
    12. {
    13.  
    14. // We don't need the cache here
    15. canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    16. canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
    17.  
    18. QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
    19. QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");
    20. curve1->attach(this);
    21. curve2->attach(this);
    22. getDataPlot();
    23.  
    24. curve1->setData(equis, ye1, 2000);
    25. curve2->setData(equis,ye2, 2000);
    26. curve1->setPen(QPen(Qt::red, 2));
    27. curve2->setPen(QPen(Qt::blue,2));
    28. curve1->setStyle (QwtPlotCurve::Lines) ;
    29. curve2->setStyle(QwtPlotCurve::Dots);
    30.  
    31. replot();
    32. }
    33.  
    34. void Vectplot::alignScales()
    35. {
    36.  
    37. canvas()->setFrameStyle(QFrame::Box | QFrame::Plain );
    38. canvas()->setLineWidth(1);
    39.  
    40. for ( int i = 0; i < QwtPlot::axisCnt; i++ )
    41. {
    42. QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i);
    43. if ( scaleWidget )
    44. scaleWidget->setMargin(0);
    45.  
    46. QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i);
    47. if ( scaleDraw )
    48. scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false);
    49. }
    50. }
    51.  
    52. void Vectplot::getDataPlot()
    53. {
    54. for (int i = 0; i < 2000; i++)
    55. {
    56. ye1[i] = i / sqrt(i) ;
    57. equis[i] = i ;
    58. ye2[i] = sin(i);
    59. }
    60. }
    To copy to clipboard, switch view to plain text mode 

    I'm sure the error is something stupid, but haven't been able to find it. If someone could, please, check this and tell me what's going on, I'd appreciate it .

    Thanks in advance,

    Claudia

  2. #2
    Join Date
    Sep 2008
    Posts
    26
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame error when subclassing QwtPlot

    I don't know what is the problem but I can suggest 2 ways :

    - I implemented a subclass of QwtPlot and my code is similar to yours. One difference is that I don't have any Qwidget parent parameter in the constructor and so, I don't call QwtPlot (at least explicitely). I have something similar to

    # Vectplot::Vectplot() {
    ....
    }

    - If it does not work, I suggest to try to implement a copy constructor for your class. It solved some similar compilations error on my project. However, I don't see any call to a copy constructor in your code so I don't think this is the problem.

    Joel.

  3. The following user says thank you to jomarin for this useful post:

    claudiacrb (30th April 2010)

Similar Threads

  1. Custom QFrame
    By fruzzo in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2009, 15:49
  2. qwtplot run time error
    By hamid ghous in forum Qwt
    Replies: 2
    Last Post: 13th August 2009, 15:33
  3. Replies: 6
    Last Post: 14th May 2009, 13:02
  4. Using css for all QFrame's except one.
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 10th July 2008, 09:05
  5. Reg - QFrame
    By suresh in forum Qt Programming
    Replies: 1
    Last Post: 1st November 2006, 05:34

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.