Skip to content

index error with QSettingsManager #30

@mc3

Description

@mc3

I’m getting

File "/Users/ajr/Projects/NET/zad/zad/views/settings.py", line 178, in setup
sc.add_handler("gen/ignored_nets", sd.ignoredListWidget)
File "/usr/local/py_env/zad/lib/python3.9/site-packages/pyqtconfig/config.py", line 877, in add_handler
handler.setter(self._get(key))
File "/usr/local/py_env/zad/lib/python3.9/site-packages/pyqtconfig/config.py", line 428, in _set_QListWidget
self.findItems(
IndexError: list index out of range

This happens if the list corresponding to the QListWidget is not empty.
I’m using pyqtconfig.QSettingsManager() and do not touch the QListWidget.
Instead I modify the settings by replacing the complete list with a modified (per GUI) one.

This is the code to access and set the list settings:


def getPrefs(self):
self.prefs = sc.get(self.listPrefName)
return

def addPref(self, value):
self.getPrefs()
self.prefs.append(value)
sc.set(self.listPrefName, self.prefs)
self.printSettings('End addPref')

def setPref(self, index, value):
self.prefs[index] = value
sc.set(self.listPrefName, self.prefs)

def delPref(self, value):
self.getPrefs()
self.prefs.remove(value)
sc.set(self.listPrefName, self.prefs)


self.prefs is the list of values.
self.listPrefName is something like ’gen/ip4_nets'
sc is the pyqtconfig.QSettingsManager instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions