S
S
Sergey Savostin2014-05-26 13:22:11
User interface
Sergey Savostin, 2014-05-26 13:22:11

How to store selected option in select?

Whether prompts who a reliable and correct way to store the option selected by the user in select?
Say, program settings, there is a selection field of N elements. The user has selected one of them - you need to save his choice in the settings file.
Because it's not a web, then the option doesn't have an id - only a serial number and the actual text.
I do not want to save the sequence number - there is a small chance that the set may change and then the saved settings will be read incorrectly. I don't want to save the selection text either - the program provides for changing the language and I would like the file to be opened in any language, and the text can change again. Where can I put this id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EXL, 2014-05-26
@savostin

@savostin don't understand what exactly your problem is. Qt has convenient classes for storing settings - QSettings. For example: there are options in the program, for example, the choice of language and QCheckBox. Let each language have an individual identifier: English - "en", Russian - "ru", Spanish - "es". The "Cool Option", characterized by QCheckBox.
Create an object of class QSettings, create methods "loadSetting()" and "saveSettings()". When the program is launched, the "loadSetting()" method reads the settings from a file or registry, and then, in accordance with the read settings, arranges the choice of options in the interface. After completion of work with the program, the "loadSetting()" method is called, which saves all user settings.

[PDA_Maze]
TimerMode=0
MapMode=1
MapSize=29
ShowStep=false
ScaleScreen=0
SmoothScreen=false
AppLanguage=ru

An example of such an implementation of saving settings can be found here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question