c++ - Segfault when adding QwtPlot to the code -
i try use qwtplot, when add line mainwindow.cpp
qwtplot *plot = new qwtplot(qwttext("demo"), this);
the application compile , link without errors, when try run get
program received signal sigsegv, segmentation fault. 0x00007ffff514227c in ?? () /usr/lib/libqtgui.so.4
without backtrace. .pro
file:
includepath += /usr/include/qwt config += qwt libs += -lqwt
i'm using qwt 6.0.2, qt creator 2.7.0 , have qt 4.8.4 , 5.0.2 installed.
the error occours when create "qt gui application" (without .ui file) , code:
qwt-test.pro
qt += core gui greaterthan(qt_major_version, 4): qt += widgets target = qwt-test template = app includepath += /usr/include/qwt config += qwt libs += -lqwt sources += main.cpp\ mainwindow.cpp headers += mainwindow.hpp
main.cpp
#include "mainwindow.hpp" #include <qapplication> #include <qdebug> int main(int argc, char *argv[]) { qdebug() << "main"; qapplication a(argc, argv); mainwindow w; w.show(); return a.exec(); }
mainwindow.hpp
#ifndef mainwindow_hpp #define mainwindow_hpp #include <qmainwindow> class mainwindow : public qmainwindow { q_object public: mainwindow(qwidget *parent = 0); ~mainwindow(); }; #endif // mainwindow_hpp
mainwindow.cpp
// mainwindow.cpp #include "mainwindow.hpp" #include <qwt_plot.h> mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent) { qwtplot *plot = new qwtplot(qwttext("demo"), this); } mainwindow::~mainwindow() { }
thanks!
it problem qt creator (or qwt being incompatible qt 5), recognized qmake qmake qt 4 qt 5. fixing versions in options -> build&run -> qt versions , using qt 4 project fixed segfault.
Comments
Post a Comment