mikrocat
10th December 2015, 11:50
Hi,
I have 2 lists of the struct DataInfo.
struct AvailableData{
quint8 type;
quint8 resolution;
quint8 quantity;
QString unit;
QString name;
};
struct DataInfo{
AvailableData Info;
quint8 flag;
quint8 number;
};
...
QList<DataInfo> AllData;
QList<DataInfo> SelectedDataWithInfo;
I fill the first list like this:
for (int j = 1; j <= DataList.at(i).quantity; j++){
DataInfo tempInfo;
tempInfo.Info = DataList.at(i);
tempInfo.number = j;
tempInfo.flag = i;
AllData.append(tempInfo);
}
Now the user of my software is able to select via checkboxes certain members of the list. So i want to create another list "SelectedDataWithInfo" which contains the selected Data.
QList<QCheckBox *> CheckBoxes = ui->AvailableDataWidget->findChildren<QCheckBox *>();
for(int i = 0; i < CheckBoxes.size(); ++i){
if(CheckBoxes.at(i)->isChecked()){
ui->transducerTable->showColumn(i+2);
if (!SelectedDataWithInfo.contains(AllData.at(i))){
SelectedDataWithInfo.append(AllData.at(i));
}
}
else{
ui->transducerTable->hideColumn(i+2);
SelectedDataWithInfo.removeOne(AllData.at(i));
}
}
But it doesn't work, it says: "no match for 'operator==' (operand types are 'MonitorWindow::DataInfo' and 'const MonitorWindow::DataInfo')
if (i->t() == t)"
What exactly did I wrong?
I have 2 lists of the struct DataInfo.
struct AvailableData{
quint8 type;
quint8 resolution;
quint8 quantity;
QString unit;
QString name;
};
struct DataInfo{
AvailableData Info;
quint8 flag;
quint8 number;
};
...
QList<DataInfo> AllData;
QList<DataInfo> SelectedDataWithInfo;
I fill the first list like this:
for (int j = 1; j <= DataList.at(i).quantity; j++){
DataInfo tempInfo;
tempInfo.Info = DataList.at(i);
tempInfo.number = j;
tempInfo.flag = i;
AllData.append(tempInfo);
}
Now the user of my software is able to select via checkboxes certain members of the list. So i want to create another list "SelectedDataWithInfo" which contains the selected Data.
QList<QCheckBox *> CheckBoxes = ui->AvailableDataWidget->findChildren<QCheckBox *>();
for(int i = 0; i < CheckBoxes.size(); ++i){
if(CheckBoxes.at(i)->isChecked()){
ui->transducerTable->showColumn(i+2);
if (!SelectedDataWithInfo.contains(AllData.at(i))){
SelectedDataWithInfo.append(AllData.at(i));
}
}
else{
ui->transducerTable->hideColumn(i+2);
SelectedDataWithInfo.removeOne(AllData.at(i));
}
}
But it doesn't work, it says: "no match for 'operator==' (operand types are 'MonitorWindow::DataInfo' and 'const MonitorWindow::DataInfo')
if (i->t() == t)"
What exactly did I wrong?