Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Cannot delete key from QSettings on iOS
Qt 6.11 is out! See what's new in the release blog

Cannot delete key from QSettings on iOS

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 1.8k Views 1 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.
  • D Offline
    D Offline
    DaRk3R
    wrote on last edited by
    #1

    Hello,

    I am using Qt 5.1 compiled to run on iOS devices and I am using QSettings to save some info that I need my app to log.

    I am saving strings under keys of the following type:
    log/date/identifier

    At some point I need to be able to get rid of these strings from QSettings. To do so I do the following:

    @mSettings.beginGroup(LOG_TAG);
    QStringList logKeys = mSettings.allKeys();
    mSettings.endGroup();
    qDebug() << "log (start-end)" << startTime << "-" << endTime;
    for(int i = 0; i < logKeys.size(); i++) {
    QDateTime time = QDateTime::fromString(logKeys[i].split("/")[0], "yyyy-MM-ddTHH:mm:ss:zzz");
    if(time >= start && time <= end) {
    qDebug() << "Delete " << (LOG_TAG + "/" + logKeys[i]);
    mSettings.remove(LOG_TAG + "/" + logKeys[i]);
    }
    }@

    Here @LOG_TAG = "log"@

    When that code runs here's what it prints out on the terminal:

    @log (start-end) "2013-08-01T14:42:54:267" - "2013-08-01T14:44:40:999"
    Delete "log/2013-08-01T14:42:54:267/ACCESSED"
    Delete "log/2013-08-01T14:42:56:120/ACCESSED"
    Delete "log/2013-08-01T14:42:57:826/ACCESSED"
    Delete "log/2013-08-01T14:44:40:999/DEVICE"@

    Immediately after, If I try and print out all the items with keys starting with LOG_TAG it outputs:

    @LOG: QMap(("2013-08-01T14:42:54:267/ACCESSED", "INFO:UserMenu")("2013-08-01T14:42:56:120/ACCESSED", "INFO:SignInMenu")("2013-08-01T14:42:57:826/ACCESSED", "INFO:WorldRanks"))@

    As you can see it successfully deleted
    @"log/2013-08-01T14:44:40:999/DEVICE"@

    but not the other keys.

    Any idea why this might be happening?

    Thanks,

    Corneliu

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

      Hi,

      Since you're using QSettings in an unusual way, did you call sync() to send the changes to permanent storage ?

      Hope it helps

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

      1 Reply Last reply
      0

      • Login

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