How to convert QVector<double> to QBytearray then display it via QPixmap?

552 views Asked by At

I have a big problem with loading and displaying the data. I'm loading data from the .csv file to QVector then convert it to QBytearray and display it via QPixmap.

Bellow are the steps with code examples:

  1. Loading data from .csv to QVector.
  2. Converting QVector to QBytearray.

    QByteArray InfraredCamera::retFrameBArray(const int* frameNumber)
    {
        Frame temp =  Pictures[*frameNumber];
        QVector<double>* vec = temp.retVecFrameValue();
        QByteArray arr = QByteArray::fromRawData(reinterpret_cast<const char*>(vec), 
                                             (vec->size())*(sizeof(double)));
        for(int i = 0; i< vec->size(); i++)
            arr.append(reinterpret_cast<const char*>(temp.retFrameValue(&i)),sizeof(double));
        return arr;
    }
    
  3. Displaying it via QPixmap:

    int x = 3; //I chose number of frame to display
    QByteArray arr = test->Termo.retFrameBArray(x);
    QPixmap pic;
    pic.loadFromData(arr);
    

Then my program crashes. What should I do with it?

Bonus question: Would have been nice if I could show some of these images as a movie. Anyone know how you can do it?

0

There are 0 answers