Important: Please read the Qt Code of Conduct -

Dynamic structure error

  • Hi to all.
    First of all thank for helping me and reading this post.

    I am trying to create a dynamic structure.
    My code is:


    typedef struct { //We define the line structure
        std::double_t x_start;
        std::double_t x_end;
        std::vector<struc_lines> lines_struct;

    Now I would like to add x_start and x_end to the structure which we do not know the size (so because of that it is a dynamic structure).

    I have tried with

     lines_struct[i].y_start=(1.25); //For example

    It compiles fine but it does not work.
    How can I use .push_back for example in lines_struct.x_start???

    Thanks a lot.

  • Lifetime Qt Champion

    You mean

    struc_lines Line;

    Now it has 1 entry so
    QDebug() << lines_struct[0].x_start;
    should give 100.

Log in to reply