Can please someone post a simple example of filling a QList of user-defined structs? I haven't found a good example so far.
E.g.:
struct MeasurementStruct {
};
QList<MeasurementStruct *> measurementTypes;
for (int i = 0; i < counterID.count(); i++)
{
measurementTypes.append(new MeasurementStruct(??????????));
}
struct MeasurementStruct {
QString counterID;
QString networkElementName;
QString netactName;
QString description;
QString object;
};
QList<MeasurementStruct *> measurementTypes;
for (int i = 0; i < counterID.count(); i++)
{
measurementTypes.append(new MeasurementStruct(??????????));
}
To copy to clipboard, switch view to plain text mode
Edited:
Found out a workaround solution:
Header:
class MeasurementStruct {
public:
MeasurementStruct::counterID = counterID;
MeasurementStruct::networkElementName = networkElementName;
MeasurementStruct::netactName = netactName;
MeasurementStruct::description = description;
MeasurementStruct::object = object;
}
};
class MeasurementStruct {
public:
MeasurementStruct(QString counterID, QString networkElementName, QString netactName, QString description, QString object){
MeasurementStruct::counterID = counterID;
MeasurementStruct::networkElementName = networkElementName;
MeasurementStruct::netactName = netactName;
MeasurementStruct::description = description;
MeasurementStruct::object = object;
}
QString counterID;
QString networkElementName;
QString netactName;
QString description;
QString object;
};
To copy to clipboard, switch view to plain text mode
Source:
{
for (int i = 0; i < counterID.count(); i++)
{
measurementTypes << new MeasurementStruct(counterID.at(i), networkElementName.at(i), "", "", "");
}
}
{
for (int i = 0; i < counterID.count(); i++)
{
measurementTypes << new MeasurementStruct(counterID.at(i), networkElementName.at(i), "", "", "");
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks