QVector<double> attributes

  • Hey qt people,

    I have a little question to make multiple attributes in my .h

    to create several objects of the same type I use this method:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QMainWindow>
    private :
    std::vector<QLCDNumber*> lcd;
    for (int i=0; i<22; i++) 
            lcd.push_back(new QLCDNumber(this));

    for lcd (objects) it works perfectly. to make vectors of QVector<double> id in the .h and use them in the .cpp how to do ?
    I have to create 90 of them and I would like to avoid writing in the .h :

        QVector<double> one_vector
        QVector<double> two_vector
        QVector<double> three_vector
        QVector<double>  xx_vector

    if you have an idea, that's cool!
    thanks all and take care of you :)

  • Lifetime Qt Champion

    @Albator said in QVector<double> attributes:

    QVector<double> 15

    What should this be?

  • it's the name if you prefer i can name this QVector<double> chips1

  • @Albator
    If the vectors are member variables they must be written in the .h.
    Or you just don't want to write 90 times in .h?
    Then how about an array of vectors, or a vector of vectors?

    QVector<double> vectors[90];


    QVector<QVector<double>> vectors;

  • @Bonnie yes is members variables

    the solution was super simple I don't know why I got confused about making std::vector<QVector<double>> xx [90];

    thanks @Bonnie :)))

Log in to reply