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 ); |