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 8376669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:28:54+00:00 2026-06-09T15:28:54+00:00

I’ve been working on my first gui application. I need to store some values

  • 0

I’ve been working on my first gui application. I need to store some values for everything to function so I decided to use QSettings and learn how to use windows registry. I have found an example for the size and position so I have do have a slight grasp on what is going on here, but for some reason I cannot get it to work when I try on my own. I have been struggling with this for a few weeks now and just cant find any good references on how to add my own strings to the registry. Below is all the pertinent code needed for this to happen. Any help or point in the right direction will be greatly appreciated. Also I have the fundamentals of Qt 4 or something like that but it was not that much help to me in this instance, so if anyone has any quick references to some quality related articles or more comprehensive works on the more advanced QT topics i would be interested to hear them, not to get to far off the topic at hand though, I’m sure there’s tons of good books out there.

MainWindow.cpp

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
createActions();
createMenus();
createMainWidget();
createIcons();
createDocks();
createStatusBar();

setMinimumSize(950,600);
setWindowTitle(tr("Black Ops Toolbox: Vrs. 0.0.0.12.01"));

QString defaultDirPath = "";

readSettings();
}

void MainWindow::readSettings()
{
QSettings settings;
QPoint pos = settings.value("pos", QPoint(25,25)).toPoint();
move(pos);
QSize size = settings.value("size",QSize(1200,900)).toSize();
resize(size);
QString defaultDirPath = settings.value("defaultDirPath", QString("c:/programfiles/")).toString();

}

void MainWindow::writeSettings()
{
QSettings settings;
settings.setValue("pos",pos());
settings.setValue("size",size());
settings.setValue("defaultDirPath", QVariant(QString *defaultDirPath).toString());
}

void MainWindow::closeEvent(QCloseEvent *event)
{
writeSettings();
}

MainWindow.h

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);

protected:
void closeEvent(QCloseEvent *event);

private:
void createActions();
void createActionEvents();
void createMenus();
void createMainWidget();
void createIcons();
void createDocks();
void createStatusBar();
void readSettings();
void writeSettings();

QString *defaultDirPath;
};
  • 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-06-09T15:28:55+00:00Added an answer on June 9, 2026 at 3:28 pm

    I really did not use QSettings yet, but from documentation it seems that in your code some information misses.

    In particular, you must give (from Basic usage section), organization name and application name, using the QSettings constructor, like

     QSettings settings("MySoft", "Star Runner");
    

    or using QCoreApplication settings and then the default QSettings constructor

     QCoreApplication::setOrganizationName("MySoft");
     QCoreApplication::setOrganizationDomain("mysoft.com");
     QCoreApplication::setApplicationName("Star Runner");
     ...
     QSettings settings;
    

    Have you tried one of these methods to create your QSettings?

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.