you can use a QDataStream
which will encode the data in binary in a specific format. (more specifically first the number of items (int32) and then each item)
QVector
has overloads for the stream operators
QByteArray line;
QDataStream stream(&line, QIODevice::WriteOnly);
stream << y;
and to read:
QVector<double> data;
QDataStream stream(line);
stream >> data;