Important: Please read the Qt Code of Conduct -

QSettings is not saving my data

  • Hello there,

    I'm trying to create an ini file which is reading file and everything, but it's not writing to my file, I have this file as a resource and here is my code

    @ QSettings test (":/configs/test.ini",QSettings::IniFormat);
    ui->label_4->setText("This is out first time");
    ui->label_4->setText("this is not out first time");

    and I tried to make it for desktop and send it to my mobile,

    But every time I only see a message which is This is our first time, and value is always 1, it never writes 0 to it.

    Also I wanted my to list my file in the .pro instead of adding it to a resource file with no success, thank you.


  • Hi,

    The resources are read-only, so nothing you modify in the QSettings object will be saved.


    You could create a new "Mobile Qt Application" project in QtCreator: it adds a deployment.pri to you project to copy files or directories to the target directory (it works for desktop application too).

    Or if you want to keep your existing project, copy the file shared/deployment.pri from QtCreator templates directory QtSDK/QtCreator/share/qtcreator/templates to your project and add the following lines (from mobileapp/ to your .pro file:
    @# To copy the whole directory
    dirToCopy.source = config

    OR if you only want to copy one file

    fileToCopy.source = config/test.ini = config # to recreate the directory in the destination




  • If you like you can take a look at the following "simple code snippet for QSettings":

  • Wow, thanks for that guys, Sorry I've been late but I just had the time to be back, have a great day ;)


Log in to reply