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. QSettings - Sync issue between two process
Forum Update on Monday, May 27th 2025

QSettings - Sync issue between two process

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k Views
  • 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.
  • K Offline
    K Offline
    kartlee
    wrote on 26 Aug 2011, 17:21 last edited by
    #1

    Hi,

    I am using Qsettings for non gui products to store its settings into xml files. This is written as a library which gets used in C, C++ programs. There will be 1 xml file file for each product. Each product might have more than one sub products and they are written into xml by subproduct grouping as follows -

    File: "product1.xml"

    @<product1>
    <subproduct1>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproduct1>
    ...
    <subproductn>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproductn>

    </product1>@

    File: productn.xml

    @<productn>
    <subproduct1>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproduct1>
    ...
    <subproductn>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproductn>

    </productn>@

    The code in one process does the following -

    @settings = new QSettings("product1.xml", XmlFormat);
    settings.setValue("settings1",<value>)
    sleep(20);
    settings.setValue("settings2", <value2>)
    settings.sync();@

    When the first process goes to sleep, I start another process which does the following -

    @settings = new QSettings("product1.xml", XmlFormat);
    settings.remove("settings1")
    settings.setValue("settings3", <value3>)
    settings.sync();@

    I would expect the settings1 to go away from product1.xml file but it still persist in the file - product1.xml at the end of above two process. I am not using QCoreApplication(..) in my settings library. Please point issues if there is anything wrong in the above design.

    -Kartlee

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 27 Aug 2011, 23:58 last edited by
      #2

      The last sync wins and that's that of process 1.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kartlee
        wrote on 28 Aug 2011, 04:36 last edited by
        #3

        Hi,

        Thanks for the reply. I realized the mistake am doing. Thanks again.

        -Karthik

        1 Reply Last reply
        0

        1/3

        26 Aug 2011, 17:21

        • Login

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