Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to reapply checkbox settings as stored in settings file
Forum Updated to NodeBB v4.3 + New Features

How to reapply checkbox settings as stored in settings file

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 362 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cerrC Offline
    cerrC Offline
    cerr
    wrote on last edited by
    #1

    I have stored checkState() items from a QWidgetList(with Qt::ItemIsUserCheckable set) in a QSettings file that I would like to restore(including the CheckState. 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`)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are always re-adding the same item rather than creating a new one each time the loop iterates.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      cerrC 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi,

        You are always re-adding the same item rather than creating a new one each time the loop iterates.

        cerrC Offline
        cerrC Offline
        cerr
        wrote on last edited by
        #3

        @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!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved