mam problem w napisaniu pętli.
QVector<double> x(4), y(4);
x[0] = a;
y[0] = b;
x[1] = c;
y[1] = d;
x[2] = e;
y[2] = f;
x[3] = g;
y[3] = h;
Oczywiscie musi byc dla n elementów .
mam problem w napisaniu pętli.
QVector<double> x(4), y(4);
x[0] = a;
y[0] = b;
x[1] = c;
y[1] = d;
x[2] = e;
y[2] = f;
x[3] = g;
y[3] = h;
Oczywiscie musi byc dla n elementów .
a czym jest a,b,c,...h ?
wartosciami na osi, według których rysuje mi wykres
Jak zamierzasz zrobić z tego pętle skoro wartości masz po różnym zmiennym porozrzucane? To niewykonalne.
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MainWindow::makePlot();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::makePlot()
{
QVector<double> x(4), y(4);
x[0] = 5;
y[0] = 5;
x[1] = 10;
y[1] = 6;
x[2] = 10;
y[2] = 23;
x[3] = 20;
y[3] = 35;
ui->customPlot->addGraph();
ui->customPlot->graph(0)->setData(x, y);
ui->customPlot->xAxis->setLabel("x");
ui->customPlot->yAxis->setLabel("y");
ui->customPlot->xAxis->setRange(0, 50);
ui->customPlot->yAxis->setRange(0, 50);
ui->customPlot->replot();
}
jak przerobic ten kod zeby mozna bylo podawac dane do rysowania wykrsu?