Qt convert data to QPixmap

672 Views Asked by At

Im trying to convert some data from QVector to QBitmap. How can I do this? I have a QVector of QPointF, and Im trying to convert that data to redraw on QPixmap.

QVector<QPointF> data;
QPixmap pixMap;

EDIT

I've made something like this. Why it isn't work?

QPainter *painter = new QPainter(&pixMap);
for(int i = 1; i < data.last().x(); i++){
  painter->setPen(QPen(Qt::black, 2));
  painter->drawPolyline(this->data.data(), this->data.size());
}
  delete painter;
  setPixmap(pixMap);
1

There are 1 best solutions below

2
On

You can just draw into a pixmap using QPainter:

QPixmap pixmap(100,100);   // a pixmap of size 100x100 pixels
QPainter painter(&pixmap);

// iterate over your points and draw them using the painter

QPainter docs have loads of examples on how to draw stuff using QPainter, brushes, pens...