Plot::Plot( QWidget *parent ): QwtPlot( parent ), d_curve( NULL ) { /*canvas()->setStyleSheet( "border: 2px solid Black;" "border-radius: 15px;" "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1," "stop: 0 LemonChiffon, stop: 1 PaleGoldenrod );" );*/ //QwtPlotCanvas *newcanvas=new QwtPlotCanvas(); //newcanvas->setPalette(Qt::white); //newcanvas->setBorderRadius(10); //setCanvas( newcanvas ); //plotLayout()->setAlignCanvasToScales( true ); setAxisTitle( QwtPlot::yLeft, "ylabel" ); setAxisTitle( QwtPlot::xBottom, "xlabel" ); //setAxisScale(QwtPlot::yLeft,0.0,25.0); //setAxisScale(QwtPlot::xBottom,0.0,25.0); //canvas()->resize(800, 600); //plotLayout(AlignScales); // attach curve d_curve = new QwtPlotCurve( "Scattered Points" ); d_curve->setPen( QColor( "Black" ) ); // d_curve->setCurveAttribute(fitten); // when using QwtPlotCurve::ImageBuffer simple dots can be // rendered in parallel on multicore systems. d_curve->setRenderThreadCount( 0 ); // 0: use QThread::idealThreadCount() //d_curve->setCurveAttribute(QwtPlotCurve::Fitted, true); d_curve->attach( this ); QwtSymbol * symbol2 = new QwtSymbol( QwtSymbol::XCross, QBrush(Qt::white), QPen(Qt::red, 1), QSize(6,6)); //QwtSymbol::Style style = Cross; setSymbol( symbol2 ); //setSymbol(NULL); // panning with the left mouse button (void )new QwtPlotPanner( canvas() ); // zoom in/out with the wheel QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() ); magnifier->setMouseButton( Qt::NoButton ); // distanve measurement with the right mouse button DistancePicker *picker = new DistancePicker( canvas() ); picker->setMousePattern( QwtPlotPicker::MouseSelect1, Qt::RightButton ); picker->setRubberBandPen( QPen( Qt::blue ) ); QwtPlotGrid *grid = new QwtPlotGrid; grid->enableX( true );//设置网格线 grid->enableY( true ); grid->setMajorPen( Qt::black, 0, Qt::DotLine ); grid->attach( this ); //QSize sizeH = sizeHint(); }
void MainWindow::enableMagnifier() //приближение-удаление { // #include <qwt_plot_magnifier.h> QwtPlotMagnifier *magnifier = new QwtPlotMagnifier(ui->Qwt_Widget->canvas()); // клавиша, активирующая приближение/удаление magnifier->setMouseButton(Qt::MidButton); }