Results 1 to 16 of 16

Thread: QwtPlot derived class

  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 11: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,309
    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,309
    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,309
    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,309
    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

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

    Default Re: QwtPlot derived class

    O.k. this one should be fine.

    What did you write in your project file: "CONFIG += qwt" ( using a proper installation following the advices from INSTALL ) or did you set the compiler/linker flags manually ?

    Uwe

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

    Default Re: QwtPlot derived class

    In my pro file I have the following entry:

    Qt Code:
    1. CONFIG(debug, debug|release) {
    2. LIBS += -lqwtd
    3. DESTDIR = debug
    4. } else {
    5. LIBS += -lqwt
    6. DESTDIR = release
    7. }
    To copy to clipboard, switch view to plain text mode 

    I thank you for your patience.

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

    Default Re: QwtPlot derived class

    No compiler flags - then you missed to set QWT_DLL.

    Uwe

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

    Default Re: QwtPlot derived class

    Ok, I will investigate further on that.

  16. #16
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlot derived class

    I had the same issue and I solved it with the advices of this topic: http://www.qtcentre.org/threads/4454...le-auto-import
    I compiled qwt 6.0.1 dynamic library with qt 4.7.4, and added it to my qt project,
    but there is a linking warning saying missing --enable-auto-import option,
    I checked the qmake.conf file in mkspecs/win32-g++, QMAKE_LFLAGS is empty,
    QMAKE_LFLAGS =
    but in qt 4.7.3, QMAKE_LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
    so I added the -Wl,-enable-auto-import to qt 4.7.4, it worked.

Similar Threads

  1. Signal do not work in derived class
    By nickla in forum Qt Programming
    Replies: 0
    Last Post: 19th March 2011, 23:25
  2. Replies: 1
    Last Post: 24th October 2010, 03:40
  3. Use QWidget derived class in Dialog
    By qtneuling in forum Qt Tools
    Replies: 2
    Last Post: 18th May 2008, 00:29
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 15:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 08: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.