checkbox and load from files
« on: 27 July 2013, 03:16:49 »
This is how i save isChecked()
Code: [Select]
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
Code: [Select]
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: checkbox and load from files
« Reply #1 on: 27 July 2013, 10:28:27 »
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();
« Last Edit: 27 July 2013, 10:33:10 by texus »

Re: checkbox and load from files
« Reply #2 on: 27 July 2013, 16:32:02 »
Yeah i know i can change value like that, but i have about 3.300 checkboxes :) Anyway thanks for help. :)