1 Attachment(s)
[Resolved] Qwt - Do not start curves on [0,0]
Hi,
I'm Irony, a Frensh student, so sorry for my English.
I have a problem with Qwt.
I have a QwtPlot, with two QwtPlotCurves, but the curves begin at the point [0,0]. How can I remove this ?
Code:
void IhmConsulterTest::initGraphique(bool typeTest)
{
//Initialization of the graphic title
ui->myPlot->setTitle(ui->comboBox->currentText());
//Background color of the graphic
ui->myPlot->setCanvasBackground(Qt::white);
//Axes Title
if(!typeTest)
ui
->myPlot
->setAxisTitle
(QwtPlot::yLeft,
QString("Température (°C)"));
else
ui
->myPlot
->setAxisTitle
(QwtPlot::yLeft,
QString("Puissance sonore (dB)"));
if(!typeTest)
else
ui
->myPlot
->setAxisTitle
(QwtPlot::xBottom,
QString("Fréquence (Hz)"));
//New curves
// Attachement
myCurve->attach(ui->myPlot);
myCurve2->attach(ui->myPlot);
QVector<double> x(5);
QVector<double> y(5);
QVector<double> y2(5);
//Color of the curves
monPenCourbe1
= QPen(Qt
::red);
monPenCourbe1.setWidth(1.5);
monPenCourbe2
= QPen(Qt
::blue);
monPenCourbe2.setWidth(1.5);
// Values of the curves
for(int i=0;i<courbe1.size();i++)
{
x.append(courbe1[i].x);
y.append(courbe1[i].capteur_interieur);
y2.append(courbe1[i].capteur_exterieur);
}
//Attachement -> data
myCurve->setSamples(x.data(),y.data(),x.size());
myCurve2->setSamples(x.data(),y2.data(),x.size());
//Attachement -> Pen
myCurve->setPen(monPenCourbe1);
myCurve2->setPen(monPenCourbe2);
//Replot
ui->myPlot->replot();
}
Attachment 8741
Could someone please help me?
Thank you in advance!
Re: Qwt - Do not start curves on [0,0]
Code:
QVector<double> x(5);
Here you create a vector filled with 5 elements - later you append to this vector leaving the first 5 elements uninitialized.
Uwe
Re: Qwt - Do not start curves on [0,0]
Thank you very much !
Code:
QVector<double> x(0);
QVector<double> y(0);
QVector<double> y2(0);
It's work ! :D