Solved How to reapply checkbox settings as stored in settings file
-
I have stored
checkState()
items from aQWidgetList
(withQt::ItemIsUserCheckable
set) in aQSettings
file that I would like to restore(including theCheckState
. i have tried the following:QSettings *sttngs = new QSettings(QSettings::NativeFormat,QSettings::UserScope,"GNU","SCAPER",nullptr); nme_set(sttngs->value("name").toString()); fname_set(sttngs->value("path").toString()); sttngs->beginGroup("tooloptions"); list = new QListWidget(this); item = new QListWidgetItem(list); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); foreach(const QString &key, sttngs->childKeys()) { Qt::CheckState state = (Qt::CheckState) sttngs->value(key).toInt(); item->setCheckState(state); item->setText(key); list->addItem(item); }
but it only gives me one list item "unrecog" that is not part of the list stored in the QSettings file (~/.config/GNU/scaper/SCAPER.conf`)
-
Hi,
You are always re-adding the same item rather than creating a new one each time the loop iterates.
-
Hi,
You are always re-adding the same item rather than creating a new one each time the loop iterates.
-
@SGaist said in How to reapply checkbox settings as stored in settings file:
Hi,
You are always re-adding the same item rather than creating a new one each time the loop iterates.
Uh! You're exactly right! Thanks for opening my eyes and pointing me in the right direction!