int main(int argc, char *argv[])
{
// The next four lines enable high dpi scaling for the application
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
QwtPlotClient w;
w.show();
return a.exec();
}
QwtPlotClient
::QwtPlotClient(QWidget *parent
){
m_ui.setupUi(this);
m_ui.plotFrame->layout()->addWidget(m_plot);
m_plot
->insertLegend
(legend,
QwtPlot::BottomLegend);
QVector<QPointF> points
{ QPointF(0,
25),
QPointF(10,
12),
QPointF(20,
20),
QPointF(30,
31),
QPointF(40,
20),
QPointF(50,
15) };
curve1->setSamples(points);
curve1
->setPen
(QPen(Qt
::red));
curve1
->setLegendAttribute
(QwtPlotCurve::LegendShowLine,
true);
curve1
->setLegendAttribute
(QwtPlotCurve::LegendShowSymbol,
true);
curve1->attach(m_plot);
m_plot
->setAxisAutoScale
(QwtPlot::xBottom,
true);
m_plot
->setAxisAutoScale
(QwtPlot::yLeft,
true);
}
int main(int argc, char *argv[])
{
// The next four lines enable high dpi scaling for the application
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication a(argc, argv);
QwtPlotClient w;
w.show();
return a.exec();
}
QwtPlotClient::QwtPlotClient(QWidget *parent)
: QDialog(parent),
m_plot(new QwtPlot)
{
m_ui.setupUi(this);
m_ui.plotFrame->layout()->addWidget(m_plot);
auto legend = new QwtLegend();
legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
m_plot->insertLegend(legend, QwtPlot::BottomLegend);
QVector<QPointF> points{ QPointF(0, 25), QPointF(10, 12), QPointF(20, 20), QPointF(30, 31), QPointF(40, 20), QPointF(50, 15) };
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->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
curve1->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, true);
curve1->attach(m_plot);
m_plot->setAxisAutoScale(QwtPlot::xBottom, true);
m_plot->setAxisAutoScale(QwtPlot::yLeft, true);
}
To copy to clipboard, switch view to plain text mode
Bookmarks