Create a QVector at runtime.
-
Hello, I am trying to create QVectors at run time. Since afterwards I will be using the datas inside of them I need to give them spesific names. (Ex. name of the received address from TCP.)
I need something like this:QString vectorName = QString::number(receivedHeader.paramAddress); QVector <int> vectorName;But of course it does not let me to do that. Is there an another and easy way to accomplish it?
-
Hello, I am trying to create QVectors at run time. Since afterwards I will be using the datas inside of them I need to give them spesific names. (Ex. name of the received address from TCP.)
I need something like this:QString vectorName = QString::number(receivedHeader.paramAddress); QVector <int> vectorName;But of course it does not let me to do that. Is there an another and easy way to accomplish it?
Normally there is no need to do that. You, as programmer should know what each vector does and where you use it.
To label your
QVectorsanyway, you could put them into aQMapand map the description to its correspondingQVector.QVector<int> vec; QString vectorName = QString::number(receivedHeader.paramAddress); QMap<QVector, QString> vectors; vectors.insert(vec, vectorName); -
Hello, I am trying to create QVectors at run time. Since afterwards I will be using the datas inside of them I need to give them spesific names. (Ex. name of the received address from TCP.)
I need something like this:QString vectorName = QString::number(receivedHeader.paramAddress); QVector <int> vectorName;But of course it does not let me to do that. Is there an another and easy way to accomplish it?
@GunkutA
If you are saying you need a collection of separateQVectors, then you must create create an array or aQVector< QVector<int> >/QList< QVector<int> >of them, as you would for anything else. C++ does not allow you to create variables with a "run-time name". -
Hello, I am trying to create QVectors at run time. Since afterwards I will be using the datas inside of them I need to give them spesific names. (Ex. name of the received address from TCP.)
I need something like this:QString vectorName = QString::number(receivedHeader.paramAddress); QVector <int> vectorName;But of course it does not let me to do that. Is there an another and easy way to accomplish it?
Normally there is no need to do that. You, as programmer should know what each vector does and where you use it.
To label your
QVectorsanyway, you could put them into aQMapand map the description to its correspondingQVector.QVector<int> vec; QString vectorName = QString::number(receivedHeader.paramAddress); QMap<QVector, QString> vectors; vectors.insert(vec, vectorName); -
@GunkutA
I may misunderstand the situation, but what's wrong withQVector <int> vectorName; vectorName.resize(receivedHeader.paramAddress);