2017-11-29 1 views
-2

Ich habe ein Problem mit dem append/incrementg der QPolygonF Werte: Ich drücke einige Punkte hinein, die ich kontinuierlich bekomme und dann die Punkte über Signal an andere Klasse senden.Einen Wert in for-Schleife anhängen

Dieser Codeblock oben entfernt die alten Punkte nach Erreichen der Konditionsnummer und sendet 5 neue Punkte mit neuem Index. Die Ausgabe lautet:

points: QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue) QPolygonF(0, newPointValue) QPolygonF(1, newPointValue)... 

Wie kann ich meine Punkte erhöhen und sie senden, ohne die alten Punkte zu löschen, so dass die Ausgabe aussieht?

points: QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue) QPolygonF(5, newPointValue) QPolygonF(6, newPointValue) QPolygonF(7, newPointValue) QPolygonF(8, newPointValue)... 

Vielen Dank!

Antwort

0

Das Programm macht genau das, was Sie tun wollen !, Wenn Sie ein kontinuierliches Inkrement wollen, tun Sie Folgendes.

QPolygonF points; 
static int indx = 0; 
for(int i= 0; i< 5; ++i) 
{ 
    double value= finalMat.at<double>(i); 
    indx += i; 
    points.push_back(QPointF((double)indx, value)); 
} 
qDebug()<<"points: " << points; 

emit updatePointsSignal(points); 
+0

Diese Schleife gibt mir 'Punkte: QPolygonF (QPointF (0, 7,31297) QPointF (1, -33,6313) QPointF (3, -0,125985) QPointF (6, 40,1209) QPointF (10, 51,4032) Punkte: QPolygonF (QPointF (0, 7.31297) QPointF (1, -33.6313) QPointF (3, -0.125985) QPointF (6, 40.1209) QPointF (10, 51.4032)) 'So geht es nicht weiter –

+0

Es sollte indx ++ sein und nicht indx + = ich; –

+0

groß ... du bekommst es jetzt. – organicoman