Results 1 to 16 of 16

Thread: QwtPlot derived class

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question QwtPlot derived class

    Hello,

    I want to create a class based upon QwtPlot. I declare it as usual:

    Qt Code:
    1. #include <Qwt/qwt_plot.h>
    2.  
    3. class myplot : public QwtPlot{
    4. Q_OBJECT
    5.  
    6. public:
    7. explicit myplot(QWidget *parent = 0);
    8.  
    9. signals:
    10.  
    11. public slots:
    12.  
    13. };
    To copy to clipboard, switch view to plain text mode 


    But I get the error:

    "During startup program exited with code 0xc0000005".

    I know it's an access violation error. But I don't know why it happens only if I create a class derived from QwtPlot. In my application there are several Qwt items and all works fine.

    What I should do to find (and fix) the issue?
    Thanks in advance
    Marco

    ps. I get the same behavior if I include the incrementalplot for example
    Last edited by Marco Trapanese; 7th February 2012 at 10:27.

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot derived class

    you could debug and search the code that is responsible for thisaccess violation.

  3. #3
    Join Date
    Jan 2012
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot derived class

    could you copy your *.cpp?
    no errors for me in the declaration

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

    Default Re: QwtPlot derived class

    This is usually a problem of your build/runtime environment and has nothing to do with the code.

    Uwe

  5. #5
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlot derived class

    Quote Originally Posted by FelixB View Post
    you could debug and search the code that is responsible for thisaccess violation.
    I wrote: "During startup [...]". That means no code is executed (better, no code visible through debug).

    Quote Originally Posted by desantossierra
    could you copy your *.cpp?
    no errors for me in the declaration

    No code in the cpp file, but the empty implementation of the constructor:

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


    I've just found I need to remove the Q_OBJECT macro. Without it runs.

    Does anyone know why?

    Quote Originally Posted by Uwe View Post
    This is usually a problem of your build/runtime environment and has nothing to do with the code.

    Maybe. But why removing the Q_OBJECT macro it works? It seems code related.

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

    Default Re: QwtPlot derived class

    Usually because your build environment doesn't handle moc and the generated cpp files properly.

    Uwe

  7. #7
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlot derived class

    Quote Originally Posted by Uwe View Post
    Usually because your build environment doesn't handle moc and the generated cpp files properly.

    Anyway, this happens only with Qwt. I have several classes that uses Q_OBJECT without problem.
    How to handle moc and cpp files properly?

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

    Default Re: QwtPlot derived class

    So that moc is called, whenever the header changes, and the generated cpp file gets compiled and linked.

    Uwe

  9. #9
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlot derived class

    Isn't this the default behavior? In fact, all classes I write but the Qwt-derived ones work.

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

    Default Re: QwtPlot derived class

    Quote Originally Posted by Marco Trapanese View Post
    Isn't this the default behavior?
    It depends on your IDE - f.e. MSVC has never heard of something like moc.

    Uwe

  11. #11
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlot derived class

    QtCreator 2.4.0

Similar Threads

  1. Signal do not work in derived class
    By nickla in forum Qt Programming
    Replies: 0
    Last Post: 19th March 2011, 22:25
  2. Replies: 1
    Last Post: 24th October 2010, 02:40
  3. Use QWidget derived class in Dialog
    By qtneuling in forum Qt Tools
    Replies: 2
    Last Post: 17th May 2008, 23:29
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

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
  •  
Qt is a trademark of The Qt Company.