Qt World Summit: Register Today!

function return array

  • Hello ,
    who can provide me an example of creating c++ function which return an array .
    then I would like to get this array in another class .
    thank you

  • Lifetime Qt Champion


    QVector<int> generateStuff() {
        QVector<int> vector {1, 2, 3};
        return vector;
    class SomeClass
    void setVector(const QVector<int> &vector);
    void soSomething();
    int main(int argc, char **argv)
        QVector<int> vector = generateStuff();
        SomeClass someClass;
        return 0;

Log in to reply