Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6849415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:59:19+00:00 2026-05-27T00:59:19+00:00

I am trying to use a QSettings object with an IniFormat for UserScope settings

  • 0

I am trying to use a QSettings object with an IniFormat for UserScope settings loaded at the start of the application. I moved the QSettings setup code into a separate method and call it from main() as shown in this snippet:

#include <QDebug>
#include <QSettings>
#include <QStringList>

void loadSettings()
{
    qDebug() << "[BEGIN] loadSettings()";

    QCoreApplication::setOrganizationName("Org");
    QCoreApplication::setApplicationName("App");

    QSettings settings(QSettings::IniFormat,
                       QSettings::UserScope,
                       "Org",
                       "App");

    settings.setValue("TheAnswer", "42");

    QStringList keys = settings.allKeys();
    qDebug() << "Loaded " << keys.size() << " keys.";

    qDebug() << "[END] loadSettings()";
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    loadSettings();

    QSettings settings;
    QStringList keys = settings.allKeys();
    qDebug() << "Settings has " << keys.size() << " keys.";

    // Empty
    qDebug() << settings.value("TheAnswer").toString();

    return a.exec();
}

The resulting output is:

[BEGIN] loadSettings()

Loaded 1 keys.

[END] loadSettings()

Settings has 0 keys.
“”

Looking at the documentation for QSettings, it states that the usage of QCoreApplication to set the organization name and application name would allow the usage of the convenience QSettings creation method from anywhere in the application, so my understanding is that the code snippet should be able to access the value stored with key “TheAnswer” that was loaded by the loadSettings() method. Yet, when I create a new QSettings object using the convenience method, it has no key/value pairs. I verified the ini file is created and has correct data. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:59:19+00:00Added an answer on May 27, 2026 at 12:59 am

    I believe the problme is that default format is QSettings::NativeFormat instead of QSettings::IniFormat, which you are using.

    I noticed that there’s a static QSettings::setDefaultFormat() function, so I would try adding this to your loadSettings() function:

    QSettings::setDefaultformat( QSettings::IniFormat );
    

    Also, once you’ve set the application/organization and default format, I don’t think you need to pass any arguments to the QSettings constructor in your loadSettings() function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the following code to write data into an excel
I am trying to use the built in .NET application settings. So for instance
I'm trying to use the IE specific conditional statements to alter class settings based
I am trying to use the following code to export tables from access to
I'm trying to use the object model of Sharepoint 2007 to make some changes
I'm trying to use EF 4.1 with Code First POCO objects against a legacy
I am trying to use an Icon in my WPF application, and some images
I'm trying to use Flash's StageVideo object through the example ActionScript file in this
Weird problem here, I'm trying to use a global function to update my settings
I have build a jar file and trying to use it in j2me application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.