#include <QApplication>
#include <QMainWindow>
#include <QDateTime>
#include <QChartView>
#include <QLineSeries>
QT_CHARTS_USE_NAMESPACE
int main(int argc, char **argv) {
QApplication application(argc, argv);
auto *series01 = new QLineSeries();
series01->setName("line01");
...
auto *series02 = new QLineSeries();
series02->setName("line02");
...
auto *chart = new QChart();
chart->legend()->hide();
chart->addSeries(series01);
chart->addSeries(series02);
series01->setUseOpenGL(true);
chart->createDefaultAxes();
chart->setTitle(QStringLiteral("Qt line chart example"));
auto *view = new QChartView(chart, nullptr);
view->setRenderHint(QPainter::Antialiasing);
view->resize(1000, 600);
view->show();
return QApplication::exec();
}
The current line chart looks like this:
How can I display their respective names for these two lines?
You only need to display their names, and the colors need to correspond, and the position and shape are not necessary.
Aucun commentaire:
Enregistrer un commentaire