checkbox and load from files

Started by wmbuRn, 27 July 2013, 03:16:49

wmbuRn

This is how i save isChecked()

bool saveUcenik1Trening(int Text)
{
std::ofstream saveFile;
saveFile.open("checkboxUcenik1.txt", std::ios::app);
    saveFile << Text;
    saveFile << " ";
saveFile.close();

return 0;
}


And it does save to file. This is how i load from "checkboxUcenik1.txt" file

std::ifstream loadFileUcenik1Trening("checkboxUcenik1.txt");
    int valueUcenik1[12];
    tgui::Checkbox::Ptr CheckBoxUcenik1[12];
if (loadFileUcenik1Trening.is_open())
{
    for (unsigned int i = 0; i < 12; ++i)
    {
     CheckBoxUcenik1[i] = Group1->get("Ucenik1Trening" + tgui::to_string(i));
     loadFileUcenik1Trening >> valueUcenik1[i];    // valueUcenik[i] 1 and 0 from file
     std::cout << valueUcenik1[i] << std::endl;  // terminal show valueUcenik have 1 and 0 loaded
     CheckBoxUcenik1[i]->check(valueUcenik1[i]);  // error here
     }
}
loadFileUcenik1Trening.close();
}
[/close]

error: no matching function for call to 'tgui::Checkbox::check(int&)' . Any idea how to fix this ?

Thank you in advance
wmbuRn

texus

#1
The check function doesn't has any parameters. Two different functions are provided to change the state of the checkbox, check and uncheck.

So the change you have to make is replacing
CheckBoxUcenik1->check(valueUcenik1);  // error here
by
if (valueUcenik1)
    CheckBoxUcenik1->check();
else
    CheckBoxUcenik1->uncheck();

wmbuRn

Yeah i know i can change value like that, but i have about 3.300 checkboxes :) Anyway thanks for help. :)