Chinaunix首页 | 论坛 | 博客
  • 博客访问: 426872
  • 博文数量: 37
  • 博客积分: 1989
  • 博客等级: 上尉
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-13 10:30
文章分类

全部博文(37)

文章存档

2013年(2)

2012年(1)

2011年(31)

2010年(1)

2009年(2)

分类: LINUX

2011-04-22 21:24:04

p, li { white-space: pre-wrap; }
鼠标滚轮放大缩小:
  1. QwtPlotMagnifier *PM = new QwtPlotMagnifier( ui->qwtPlot->canvas() );
鼠标左键拖动波形:
  1. QwtPlotPanner *PQ= new QwtPlotPanner( ui->qwtPlot->canvas() );
鼠标左键选择区域放大:(右键还原)
  1. QwtPlotZoomer* zoomer = new QwtPlotZoomer( ui->qwtPlot->canvas() );
  2. zoomer->setRubberBandPen( QColor( Qt::black ) );
  3. zoomer->setTrackerPen( QColor( Qt::black ) );
  4. zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier );
  5. zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton );
设置X轴下面标识:
  1. ui->qwtPlot->setAxisTitle(QwtPlot::xBottom, "x -->" );
设置X轴取值范围:
  1. ui->qwtPlot->setAxisScale(QwtPlot::xBottom, 0.0, 30.0);
设置Y轴左边标识(竖着显示):
  1. ui->qwtPlot->setAxisTitle(QwtPlot::yLeft, "y -->");
设置Y轴取值范围:
  1. ui->qwtPlot->setAxisScale(QwtPlot::yLeft, -1.0, 1.0);
创建一个sin()曲线:
  1. QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
  2. cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
  3. cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
  4. cSin->setPen(QPen(Qt::blue));
  5.  cSin->attach(ui->qwtPlot);
  6. cSin->setData(new FunctionData(::sin));
其中FunctionData为:
class FunctionData: public QwtSyntheticPointData { public: FunctionData(double(*y)(double)): QwtSyntheticPointData(100), d_y(y) { } virtual double y(double x) const { return d_y(x); } private: double(*d_y)(double); };
  1. class FunctionData: public QwtSyntheticPointData
  2. {
  3. public:
  4.     FunctionData(double(*y)(double)):
  5.         QwtSyntheticPointData(100),
  6.         d_y(y)
  7.     {
  8.     }
  9.     virtual double y(double x) const
  10.     {
  11.         return d_y(x);
  12.     }
  13. private:
  14.     double(*d_y)(double);
  15. };
创建波形标识:(Y=0) QwtPlotMarker *mY = new QwtPlotMarker(); mY->setLabel(QString::fromLatin1("y = 0")); mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); mY->setLineStyle(QwtPlotMarker::HLine); mY->setYValue(0.0); mY->attach(ui->qwtPlot);
  1. QwtPlotMarker *mY = new QwtPlotMarker();
  2.     mY->setLabel(QString::fromLatin1("y = 0"));
  3.     mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  4.     mY->setLineStyle(QwtPlotMarker::HLine);
  5.     mY->setYValue(0.0);
  6.     mY->attach(ui->qwtPlot);
创建波形标识:(X=PI/2) QwtPlotMarker *mX = new QwtPlotMarker(); mX->setLabel(QString::fromLatin1("x = PI/2")); mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom); mX->setLabelOrientation(Qt::Vertical); mX->setLineStyle(QwtPlotMarker::VLine); mX->setLinePen(QPen(Qt::black, 1, Qt::DashDotDotLine)); mX->setXValue(M_PI/2); mX->attach(ui->qwtPlot);
  1. QwtPlotMarker *mX = new QwtPlotMarker();
  2.     mX->setLabel(QString::fromLatin1("x = PI/2"));
  3.     mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
  4.     mX->setLabelOrientation(Qt::Vertical);
  5.     mX->setLineStyle(QwtPlotMarker::VLine);
  6.     mX->setLinePen(QPen(Qt::black, 1, Qt::DashDotDotLine));
  7.     mX->setXValue(M_PI/2);
  8.     mX->attach(ui->qwtPlot);
设置qwtPlot的画布:(圆角矩形) ui->qwtPlot->canvas()->setLineWidth( 1 ); ui->qwtPlot->canvas()->setFrameStyle( QFrame::Box | QFrame::Plain ); ui->qwtPlot->canvas()->setBorderRadius( 15 );
  1. ui->qwtPlot->canvas()->setLineWidth( 1 );
  2.     ui->qwtPlot->canvas()->setFrameStyle( QFrame::Box | QFrame::Plain );
  3.     ui->qwtPlot->canvas()->setBorderRadius( 15 );
设置qwtPlot的画布:(白色填充) QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); ui->qwtPlot->canvas()->setPalette( canvasPalette );
  1. QPalette canvasPalette( Qt::white );
  2.     canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
  3.     ui->qwtPlot->canvas()->setPalette( canvasPalette );
设置整个界面的颜色: QPalette pal = palette(); const QColor buttonColor = pal.color( QPalette::Button ); QLinearGradient gradient( 0, 0, 0, 1 ); gradient.setCoordinateMode( QGradient::StretchToDeviceMode ); gradient.setColorAt( 0.0, Qt::white ); gradient.setColorAt( 0.7, buttonColor ); gradient.setColorAt( 1.0, buttonColor ); pal.setBrush( QPalette::Window, gradient ); setPalette( pal );
  1. QPalette pal = palette();
  2.     const QColor buttonColor = pal.color( QPalette::Button );
  3.     QLinearGradient gradient( 0, 0, 0, 1 );
  4.     gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
  5.     gradient.setColorAt( 0.0, Qt::white );
  6.     gradient.setColorAt( 0.7, buttonColor );
  7.     gradient.setColorAt( 1.0, buttonColor );
  8.     pal.setBrush( QPalette::Window, gradient );
  9.     setPalette( pal );

阅读(17822) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~