Results 1 to 3 of 3

Thread: Inheriting QwtPlot and Q_OBJECT

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Inheriting QwtPlot and Q_OBJECT

    Dear all,

    I'm trying to inherite QwtPlot and using signals/slots. So, my header file looks like:

    #pragma once
    #include "qwt_plot.h"

    #include <QtGui>

    class MyQwtCurvePlot :
    public QwtPlot
    {
    Q_OBJECT

    public:
    MyQwtCurvePlot(QWidget *p = 0);
    ~MyQwtCurvePlot(void);

    public slots:
    void highlight(const QVector<QPointF> &pa);
    };


    But, while compiling this with the Q_OBJECT macro, the compiler (MSVC2008) gives an error, namely:

    1>Generating Code...
    1>Compiling...
    1>moc_MyQwtCurvePlot.cpp
    1>Linking...
    1> Creating library K:\TEST\Qt\test\Debug\test.lib and object K:\TEST\Qt\test\Debug\test.exp
    1>moc_MyQwtCurvePlot.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlot::staticMetaObject" (?staticMetaObject@QwtPlot@@2UQMetaObject@@B)
    1>K:\TEST\Qt\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals
    1>Build log was saved at "file://k:\TEST\Qt\test\test\Debug\BuildLog.htm"


    Does anyone have an idea where this comes from? The class compiles perfectly with Q_OBJECT removed, but then the signal/slot system doesn't work.

    Thanks for replies in advance,

    Martijn
    Last edited by gpsgek; 29th March 2010 at 11:17.

  2. #2
    Join Date
    Aug 2009
    Posts
    52
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inheriting QwtPlot and Q_OBJECT

    add DEFINES += QWT_DLL to .pro file when you use windows.

  3. #3
    Join Date
    Sep 2010
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Smile Re: Inheriting QwtPlot and Q_OBJECT

    Add QWT_DLL in project properties->c++->preprocessor->definitions if you are using VS for Qt..

  4. The following user says thank you to nitinkamkar for this useful post:

    theofthe (2nd October 2014)

Similar Threads

  1. Replies: 1
    Last Post: 23rd February 2010, 15:57
  2. A Object inheriting from QGraphicsLineItem
    By jano_alex_es in forum Newbie
    Replies: 15
    Last Post: 15th July 2009, 09:25
  3. Replies: 6
    Last Post: 14th May 2009, 12:02
  4. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51
  5. Inheriting QListViewItem
    By ct in forum Newbie
    Replies: 1
    Last Post: 17th March 2006, 05:52

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.