QPainter::drawPolyline() takes an array of points and the number of points to draw so you can obtain what you want using this simple loop:

QVector<QPoint> points;

// fillWithData(points);

//...

int start = 0;

for(int i=0;i<points.size();i++){

if(pt.x()==-9 || pt.y()==-9){

// draw from start to the current point

if(start!=i){

painter.drawPolyline(points.constData()+start, i-start);

}

start = i;

}

}

if(start!=points.size()-1){

painter.drawPolyline(points.constData()+start, points.size()-1-start);

}

QVector<QPoint> points;
// fillWithData(points);
//...
int start = 0;
for(int i=0;i<points.size();i++){
QPoint pt = points.at(i);
if(pt.x()==-9 || pt.y()==-9){
// draw from start to the current point
if(start!=i){
painter.drawPolyline(points.constData()+start, i-start);
}
start = i;
}
}
if(start!=points.size()-1){
painter.drawPolyline(points.constData()+start, points.size()-1-start);
}

*To copy to clipboard, switch view to plain text mode *

## Bookmarks