jeudi 23 janvier 2020

save and load modifications with qsettings

I have 2 windows ( window 1 ) & ( window 2 ) : see pictures. -On window 1 there is an "edit" button that should open window 2 ( and load modifs saved on window 2 ) -On window 2, I have 96 buttons which are initially green, if I click on one it becomes red. The "OK" button that I have should close window 2 and save the modifications ( red buttons ). If I re-open window 2 by clicking on the "edit" button of window 1, the red buttons of the last step should stay red and become uncheckable. How can I do that with QSettings ? This is my code of the savesettings method : ( I don't know if it is correct or not but I think yes !)

void Vessels::SaveSettings()
{
        QSettings setting("My_vessels","My_selected_vessels");
        setting.beginGroup("Vessels");
        if (ui->pushButton_4->isChecked()){
        ui->pushButton_4->setCheckable(false);}
        setting.setValue("selected",ui->pushButton_4->isCheckable());
        setting.endGroup();
}

I am facing 2 problems : 1) The save and load buttons ( which are in this case respectively "OK" and "Edit" ) are not from the same window. 2) I don't know how to implement the loadSettings method that I should append to the "Edit" button.

enter image description here

Aucun commentaire:

Enregistrer un commentaire