is there a way that I can check whether QSettings is using the default value?
For example:
def setup_ui(self):
self.user_input = QtGui.QLineEdit()
self.user_input.setText("Input something...")
...
...
# Check for any stored settings
self.user_input.setText(self.settings.value("userInput", "Input something..."))
def load_settings(self):
self.settings = QtCore.QSettings('TEST', 'My_Tool')
input = self.settings.value("userInput", "Input something...")
def save_settings(self):
settings = QtCore.QSettings('TEST', 'My_Tool')
settings.setValue('userInput', self.user_input.currentText())
If I am re-launching my tool, there are some functions which will be using the current text string in the QLineEdit. So far, in order for me to bypass the default value, I have coded my functions as follows:
def test_func(self, input_text):
if not input_text == 'Input something...':
# Do something...
Your question is equivalent to asking if the key exists so you must use the contains()
method:
if settings.contains("userInput"):
# there is the key in QSettings
else:
# there is no key in QSettings