QT QWT类使用方法总结

更新时间:2023-07-25 16:26:46 阅读: 评论:0


QT QWT类使用方法总结 
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->tRubberBandPen( QColor( Qt::black ) );
3. zoomer->tTrackerPen( QColor( Qt::black ) );
4. zoomer->tMouPattern(QwtEventPattern::MouSelect2,Qt::RightButton, Qt::ControlModifier );
5. zoomer->tMouPattern(QwtEventPattern::MouSelect3,Qt::RightButton );
设置X轴下面标识:
1. ui->qwtPlot->tAxisTitle(QwtPlot::xBottom,"x -->");
设置X轴取值范围:
1. ui->qwtPlot->tAxisScale(QwtPlot::xBottom, 0.0, 30.0);
设置Y轴左边标识(竖着显示):
1. ui->qwtPlot->tAxisTitle(QwtPlot::yLeft,"y -->");
设置Y轴取值范围:
1. ui->qwtPlot->tAxisScale(QwtPlot::yLeft,-1.0, 1.0);
创建一个sin()曲线:
1. QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
2. cSin->tRenderHint(QwtPlotItem::RenderAntialiad);
3. cSin->tLegendAttribute(QwtPlotCurve::LegendShowLine,true);
4. cSin->tPen(QPen(Qt::blue));
5.  cSin->attach(ui->qwtPlot);
6. cSin->tData(new FunctionData(::sin));
其中FunctionData为:
classFunctionData:publicQwtSyntheticPointData {public:FunctionData(double(*y)(double)):QwtSyntheticPointData(100),d_y(y){}virtualdoubley(doublex)const{returnd_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=newQwtPlotMarker();mY->tLabel(QString::fromLatin1("y=0"));mY->tLabelAlignment(Qt::AlignRight|Qt::AlignTop);mY->tLineStyle(QwtPlotMarker::HLine);mY->tYValue(0.0入盆多久会生);mY->attach(ui->qwtPlot);
1. QwtPlotMarker *mY = new QwtPlotMarker();
宝宝认字
2.     mY->tLabel(QString::fromLatin1("y = 0"));
3.     mY->tLabelAlignment(Qt::AlignRight|Qt::AlignTop);
4.     mY->tLineStyle(QwtPlotMarker::HLine);
5.     mY->tYValue(0.0);
6.     mY->attach(ui->qwtPlot);
创建波形标识:(X=PI/2) QwtPlotMarker*mX=newQwtPlotMarker();mX->tLabel(QString::fromLatin1("x=PI/2"));mX->tLabelAlignment(Qt::AlignLeft|Qt::AlignBottom);mX->tLabelOrientation(Qt::Vertical);mX->tLineStyle(QwtPlotMarker::VLine);mX->tLinePen(QPen(Qt::black,1,Qt::DashDotDotLine));mX->tXValue(M_PI/古诗红豆2);mX->attach(ui->qwtPlot);
1. QwtPlotMarker *mX = new QwtPlotMarker();
2.     mX->tLabel(QString::fromLatin1("x = PI/2"));
3.     mX->tLabelAlignment(Qt::AlignLeft | 窦州Qt::AlignBottom);
4.     mX->tLabelOrientation(Qt::Vertical);
5.     mX->tLineStyle(QwtPlotMarker::VLine);
6.     mX->tLinePen(QPen(Qt::black, 1, Qt::DashDotDotLine));
7.     mX->tXValue(M_PI/2);
8.     mX->attach(ui->qwtPlot);
设置qwtPlot的画布:(圆角矩形) ui->qwtPlot->canvas()->tLineWidth(1);ui->qwtPlot->canvas()->tFrameStyle(QFrame::Box|QFrame::Plain);ui->qwtPlot->canvas()->tBorderRadius(15);
1. ui->qwtPlot->canvas()->tLineWidth( 1 );
2.     ui->qwtPlot->canvas()->tFrameStyle( QFrame::Box | QFrame::Plain中国禁毒史 );
3.     ui->qwtPlot->canvas()->tBorderRadius( 15 );
设置qwtPlot的画布:(白色填充) QPalettecanvasPalette(Qt::white);canvasPalette.tColor(QPalette::Foreground,QColor(133,190,232));ui->qwtPlot->canvas()->tPalette(canvasPalette);
1. QPalette canvasPalette( Qt::white );
2.     canvasPalette.tColor( QPalette::Foreground, QColor( 133, 黄巾军起义190, 232 ));
3.     ui->qwtPlot->canvas()->tPalette( canvasPalette );
设置整个界面的颜色: QPalettepal=palette();constQColorlor(QPalette::Button);QLinearGradientgradient(0,0,0,1);gradient.tCoordinateMode(QGradient::StretchToDeviceMode);gradient.tColorAt(0.0,Qt::white);gradient.tColorAt(0.7,buttonColor);gradient.tColorAt(1.0,buttonColor);pal.tBrush(QPalette::Window,gradient);tPalette(pal);
1. QPalette pal = palette();
2.     const QColor buttonColor = lor( QPalette::Button );
3.     QLinearGradient gradient( 0, 0, 0, 1 );
4.     gradient.tCoordinateMode( QGradient::StretchToDeviceMode );
5.     gradient.tColorAt( 0.0, Qt::white );
6.     gradient.tColorAt( 0.7, buttonColor );
7.     gradient.tColorAt( 1.0, buttonColor );
8.     pal.tBrush( QPalette::Window, gradient );
9.     tPalette( pal );

本文发布于:2023-07-25 16:26:46,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1116682.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:设置   放大   画布   鼠标   标识
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图