I have a class Variable
, extension of QWidget
. I want to add it to the vector QVector <Variable> *list_variables
, but when I try, I get the error
Attempt to refer to a deleted function
Here is the code :
QVector <Variable> *list_variables;
QVBoxLayout *layout = new QVBoxLayout (scroll_area);
for (int i = 0; i < 5; i ++)
{
Variable *variable = new Variable;
list_variables->append(*variable); // Error happens here
layout->addWidget(variable);
}
Variable.h :
#ifndef VARIABLE_H
#define VARIABLE_H
#include "constant.h"
class Variable : public QWidget
{
public :
Variable();
private :
QLineEdit *line_edit_name, *line_edit_value, *line_edit_imprecision;
};
#endif // VARIABLE_H
Variable.cpp :
#include "constant.h"
Variable::Variable()
{
this->setFixedSize(240, 30);
line_edit_name = new QLineEdit(this);
line_edit_name->setGeometry(0, 0, 50, 20);
line_edit_name->setPlaceholderText("Name");
line_edit_value = new QLineEdit (this);
line_edit_value->setGeometry(60, 0, 80, 20);
line_edit_value->setPlaceholderText("Value");
line_edit_imprecision = new QLineEdit (this);
line_edit_imprecision->setGeometry(150, 0, 80, 20);
line_edit_imprecision->setPlaceholderText("Imprecision");
}
All the includes are done in "constant.h"