1.QWT
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.
2.安装Qwt
a. cd /path/to/qwt
b. qmake
c. make -j 4
d. sudo make install
以上方法会将qwt安装到/usr/local/qwt-6.1.2
3.测试Qwt是否安装成功
3.1 LearnQwt
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