#include(
$${PWD}/../examples.pri
)//把原来的.pro文件这句去掉,改成下面的代替,我是编译完qwt再来看例子的,qwt目录下包涵所需要的头文件与库文件
INCLUDEPATH += .././qwt/
LIBS += .././qwtd.dll
QT += opengl //因为需要使用到opengl.所以这句要加上.#include <qapplication.h> #include "plot.h" #ifndef QWT_NO_OPENGL #define USE_OPENGL 1 #endif #if USE_OPENGL //#include <qgl.h> #include <QtOpenGL/qgl.h> #include <qwt_plot_glcanvas.h> #else #include <qwt_plot_canvas.h> #endif int main ( int argc, char **argv ) { #if USE_OPENGL #if QT_VERSION >= 0x040600 && QT_VERSION < 0x050000 // on my box QPaintEngine::OpenGL2 has serious problems, f.e: // the lines of a simple drawRect are wrong. QGL::setPreferredPaintEngine( QPaintEngine::OpenGL ); //OpengGL作为图形绘制引擎放在<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><pre name="code" class="cpp">QApplication a( argc, argv );之前 #endif #endif QApplication a( argc, argv ); Plot plot; #if USE_OPENGL QwtPlotGLCanvas *canvas = new QwtPlotGLCanvas(); canvas->setFrameStyle( QwtPlotGLCanvas::NoFrame ); #else QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setFrameStyle( QFrame::NoFrame ); canvas->setPaintAttribute( QwtPlotCanvas::BackingStore, false ); #endif plot.setCanvas( canvas ); plot.setCanvasBackground( QColor( 30, 30, 50 ) ); plot.resize( 400, 400 ); plot.show(); return a.exec(); }