Results 1 to 6 of 6

Thread: Inheriting from QwtPlotCurve problems

  1. #1
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Inheriting from QwtPlotCurve problems

    Hi

    I have a my Curve class derived from QwtPlotCurve as shown
    Qt Code:
    1. class Curve :public QwtPlotCurve {
    2. Q_OBJECT;
    3. public:
    4. Curve(QWidget* parent, QString s,QColor colour,int size);
    5. virtual ~Curve();
    6. QCheckBox* checkBox;
    7. float* plotData;
    8. int size;
    9. signals:
    10. void doPlotUpdate();
    11. };
    12.  
    13. Curve::Curve(QWidget* parent,QString s,QColor color,int size):
    14. checkBox(new QCheckBox(s)),
    15. plotData(new float[size]),
    16. size(size)
    17. {
    18. setPen(QPen(color));
    19. QObject::connect(this->checkBox,SIGNAL(stateChanged(int)),parent, SLOT(updatePlots()));
    20. }
    To copy to clipboard, switch view to plain text mode 

    My intention is to connect the signal from the checkbox to the slot updatePlots so that when the checkbox is enabled the plot is displayed. I am getting the following linking error

    debug\moc_QwtSeahawkPlot.cpp:42: error: `staticMetaObject' is not a member of `QwtPlotCurve'
    debug\moc_QwtSeahawkPlot.cpp: In member function `virtual void* Curve::qt_metacast(const char*)':
    debug\moc_QwtSeahawkPlot.cpp:56: error: `qt_metacast' is not a member of `QwtPlotCurve'
    debug\moc_QwtSeahawkPlot.cpp: In member function `virtual int Curve::qt_metacall(QMetaObject::Call, int, void**)':
    debug\moc_QwtSeahawkPlot.cpp:61: error: `qt_metacall' is not a member of `QwtPlotCurve'
    debug\moc_QwtSeahawkPlot.cpp: In member function `void Curve::doPlotUpdate()':

    Also when I call attach I get the following compilation error.

    Qt Code:
    1. mycurve=new Curve(this,"Input Data","yellow",1024);
    2. mycurve->attach(plot);
    To copy to clipboard, switch view to plain text mode 

    c:/Qt/4.5.0/include/qwt./qwt_plot_item.h: In member function `void QwtSeahawkPlot::updatePlots()':
    c:/Qt/4.5.0/include/qwt./qwt_plot_item.h:117: error: `void QwtPlotItem::attach(QwtPlot*)' is inaccessible
    SeaHawkDebug\QwtSeahawkPlot.cpp:127: error: within this context
    SeaHawkDebug\QwtSeahawkPlot.cpp:127: error: `QwtPlotItem' is not an accessible base of `Curve'
    mingw32-make[1]: *** [debug/QwtSeahawkPlot.o] Error 1

    Could someone help me out

    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Inheriting from QwtPlotCurve problems

    QwtPlotCurve is no QObject.

  3. #3
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Inheriting from QwtPlotCurve problems

    Thanks

    OK, if I inherit from QObject and include the QObject macro as show
    Qt Code:
    1. class Curve :public QObject , QwtPlotCurve {
    2. Q_OBJECT;
    3. public:
    4. Curve(QWidget* parent, QString s,QColor colour,int size);
    To copy to clipboard, switch view to plain text mode 

    The program compiles fine, however if I try and access QwtPlotCurve methods
    Qt Code:
    1. mycurve=new Curve(this,"Input Data","yellow",x_samples);
    2. mycurve->attach(plot);
    To copy to clipboard, switch view to plain text mode 

    I get the following error

    c:/Qt/4.5.0/include/qwt./qwt_plot_item.h: In constructor `QwtSeahawkPlot::QwtSeahawkPlot(QMainWindow*, SeaHawk*)':
    c:/Qt/4.5.0/include/qwt./qwt_plot_item.h:117: error: `void QwtPlotItem::attach(QwtPlot*)' is inaccessible
    mingw32-make[1]: Leaving directory `D:/Projects/SeaHawkPC/Eclipse/QtSeaHawkPlots-Inheritance'
    SeaHawkDebug\QwtSeahawkPlot.cpp:112: error: within this context
    SeaHawkDebug\QwtSeahawkPlot.cpp:112: error: `QwtPlotItem' is not an accessible base of `Curve'

    What am I doing wrong?

    Thanks
    Last edited by dbrmik; 1st April 2009 at 10:54. Reason: updated contents

  4. #4
    Join Date
    Mar 2009
    Posts
    22
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inheriting from QwtPlotCurve problems

    Hi,
    Maybe this works:

    Qt Code:
    1. class Curve :public QwtPlotCurve, public QObject {
    2. ...
    To copy to clipboard, switch view to plain text mode 


    Hüseyin

  5. #5
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Inheriting from QwtPlotCurve problems

    No

    I'm afraid it doesn't, I get the same error and a compiler warning

    Warning: Class Curve inherits from two QObject subclasses QwtPlotCurve and QObject. This is not supported!

  6. #6
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Inheriting from QwtPlotCurve problems

    Hi

    I've solved the problem temporarily by not inheriting from QObject and not using the Q_Object macro. I dont know why it works but it does for now

    Thanks everyone

Similar Threads

  1. Replies: 2
    Last Post: 18th December 2008, 07:43

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.