Saturday, 31 August 2013

Using a subset of a QVector in a function

Using a subset of a QVector in a function

How to send a portion of a QVector to a function?
QVector<int> a;
a.append(1);
a.append(2);
a.append(3);
a.append(4);
a.append(5);
Some printing function should print "2 3 4" taking the subset of the
vector as an argument.
In R this would be possible using a[2:4].
Is this at all possible?
Note: In the std::vector, it is advised to use the insert function to
create a new variable. This is a different insert though than QVector has,
and thus I cannot find a recommended method.

No comments:

Post a Comment