QwtPlotClient
::QwtPlotClient(QWidget *parent
){
m_ui.setupUi(this);
m_ui.plotFrame->layout()->addWidget(m_plot);
curve1->setSamples(points);
curve1
->setPen
(QPen(Qt
::red));
curve1->attach(m_plot);
connect(m_ui.initButton, &QPushButton::clicked, this, [this]()
{
// Step 1: linear scale engine, auto scale off, range to [1;100]
m_plot
->setAxisAutoScale
(QwtPlot::yLeft,
false);
m_plot
->setAxisScale
(QwtPlot::yLeft,
1,
100);
m_plot->replot();
});
connect(m_ui.autoScaleOnButton, &QPushButton::clicked, this, [this]()
{
// Step 2: auto scale on
m_plot
->setAxisAutoScale
(QwtPlot::yLeft,
true);
m_plot->replot();
});
connect(m_ui.autoScaleOffButton, &QPushButton::clicked, this, [this]()
{
// Step 3: auto scale off
m_plot
->setAxisAutoScale
(QwtPlot::yLeft,
false);
m_plot->replot();
});
connect(m_ui.logButton, &QPushButton::clicked, this, [this]()
{
// Step 4: apply log scale engine
m_plot
->setAxisScaleEngine
(QwtPlot::yLeft,
new QwtLogScaleEngine
());
m_plot->replot();
});
}
QwtPlotClient::QwtPlotClient(QWidget *parent)
: QDialog(parent),
m_plot(new QwtPlot)
{
m_ui.setupUi(this);
m_ui.plotFrame->layout()->addWidget(m_plot);
m_plot->axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating, true);
auto points = QVector<QPointF>() << QPointF(0, 1) << QPointF(1, 3) << QPointF(2, 7) << QPointF(3, 12) << QPointF(4, 18);
auto curve1 = new QwtPlotCurve("Curve 1");
curve1->setSamples(points);
curve1->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::red), QPen(Qt::darkRed), QSize(8, 8)));
curve1->setPen(QPen(Qt::red));
curve1->setCurveAttribute(QwtPlotCurve::Fitted, true);
curve1->attach(m_plot);
connect(m_ui.initButton, &QPushButton::clicked, this, [this]()
{
// Step 1: linear scale engine, auto scale off, range to [1;100]
m_plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine());
m_plot->setAxisAutoScale(QwtPlot::yLeft, false);
m_plot->setAxisScale(QwtPlot::yLeft, 1, 100);
m_plot->replot();
});
connect(m_ui.autoScaleOnButton, &QPushButton::clicked, this, [this]()
{
// Step 2: auto scale on
m_plot->setAxisAutoScale(QwtPlot::yLeft, true);
m_plot->replot();
});
connect(m_ui.autoScaleOffButton, &QPushButton::clicked, this, [this]()
{
// Step 3: auto scale off
m_plot->setAxisAutoScale(QwtPlot::yLeft, false);
m_plot->replot();
});
connect(m_ui.logButton, &QPushButton::clicked, this, [this]()
{
// Step 4: apply log scale engine
m_plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine());
m_plot->replot();
});
}
To copy to clipboard, switch view to plain text mode
Bookmarks