Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. QChart *chart = new QChart(); // has no parent!
  2. chart->legend()->hide();
  3.  
  4. QLineSeries *series = new QLineSeries(chart);
  5. chart->addSeries(series);
  6. chart->createDefaultAxes();
  7. chart->layout()->setContentsMargins(0, 0, 0, 0);
  8.  
  9. QChartView *chartView = new QChartView(chart);
  10.  
  11. dialog = new QDialog(this);
  12. QVBoxLayout *layout = new QVBoxLayout;
  13. layout->addWidget(chartView);
  14. dialog->setLayout(layout);
  15.  
  16. connect(dialog, &QObject::destroyed, [this, index](){
  17. plots_cn0.erase(index.row());
  18. });
  19.  
  20. connect(&updateTimer, &QTimer::timeout, [this, series, index](){
  21. QVector<QPointF> points;
  22. QList<QVariant> var = index.data(Qt::DisplayRole).toList();
  23. for(int i = 0; i < var.size(); i++)
  24. {
  25.     points << var.at(i).toPointF();
  26. }
  27.  
  28. series->replace(points);
  29. });
  30.  
  31. plots_cn0[index.row()] = qMakePair(chart, dialog);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement