1.QWTapp
Qwt (http://sourceforge.jp/projects/sfnet_qwt/)is a graphics extension to the Qt GUI application framework from Trolltech AS of Norway. It provides a 2D plotting widget and more.ide
2.安裝Qwt測試
a. cd /path/to/qwtui
b. qmake
spa
c. make -j 4code
d. sudo make installget
以上方法會將qwt安裝到/usr/local/qwt-6.1.2qt
3.測試Qwt是否安裝成功it
3.1 LearnQwtio
A. LearnQwt.pro
QT +=core gui include(/usr/local/qwt-6.1.2/features/qwt.prf) INCLUDEPATH += /usr/local/qwt-6.1.2/lib/qwt.framework/Versions/6/Headers TARGET = LearnQwt TEMPLATE = app SOURCES += \ main.cxx LIBS += -F"/usr/local/qwt-6.1.2/lib/qwt.framework" LIBS += -framework qwt
B. main.cxx
p, li { white-space: pre-wrap; } //std #include <cmath> //qwt #include <qwt_series_data.h> #include <qwt_plot_curve.h> #include <qwt_plot.h> #include <qwt_point_data.h> //qt #include <QApplication> class SinusData : public QwtSyntheticPointData { public: SinusData(): QwtSyntheticPointData(100) {} virtual double y(double x) const { return qSin(x); } }; int main(int argc, char **argv) { QApplication app(argc,argv); QwtPlot plot; plot.setAxisScale( QwtPlot::xBottom, 0.0, 10.0); plot.setAxisScale( QwtPlot::yLeft, -1.0, 1.0); QwtPlotCurve *curve = new QwtPlotCurve("y = sin(x)"); curve->setData(new SinusData()); curve->attach(&plot); plot.show(); return app.exec(); }
C. 終端下運行LearnQwt.app
export DYLD_FRAMEWORK_PATH="/usr/local/qwt-6.1.2/lib/"
這點實在無語,和Linux平臺的LD_LIBRARY_PATH起着同樣的做用。不然會提示
dyld: Library not loaded: qwt.framework/Versions/6/qwt
LearnQwt.app/Contents/MacOS/LearnQwt
D. 運行結果以下:
4.總結。
在PRO文件中LIBS += -F "/path/to/lib" -framework(f) qwt
include("/path/to/qwt.pri")
export DYLD_FRAMEWORK_PATH="/path/to/lib"
Terminal: ./xxx.app/Contents/MacOS/xxx