def __init__(self, parent, tree, providerName, param): QTreeWidgetItem.__init__(self, parent) self.providereName = providerName self.param = param self.tree = tree self.setText(0, param.description) self.paramName = settingName(providerName, param.name) if isinstance(param.defaultValue, bool): self.value = QSettings().value(self.paramName, defaultValue=param.defaultValue, type=bool) if self.value: self.setCheckState(1, Qt.Checked) else: self.setCheckState(1, Qt.Unchecked) elif isinstance(param.defaultValue, list): self.combo = QComboBox() for element in param.defaultValue: self.combo.addItem(element) self.tree.setItemWidget(self, 1, self.combo) self.value = QSettings().value(self.paramName, defaultValue=param.defaultValue[0]) idx = self.combo.findText(self.value) self.combo.setCurrentIndex(idx) elif param.description == "Password": self.passwordField = QLineEdit() self.passwordField.setEchoMode(QLineEdit.Password); #self.passwordField.setStyleSheet("QLineEdit { border: none }"); self.value = QSettings().value(self.paramName, defaultValue=param.defaultValue) self.passwordField.setText(str(self.value)) self.tree.setItemWidget(self, 1, self.passwordField) elif param.action is not None: layout = QHBoxLayout() layout.setMargin(0) layout.setSpacing(0) self.textbox = QLineEdit() self.value = QSettings().value(self.paramName, defaultValue=param.defaultValue) self.textbox.setText(str(self.value)) layout.addWidget(self.textbox) self.button = QToolButton() self.button.setText(param.actionText) self.button.clicked.connect(param.action) layout.addWidget(self.button) self.widget = QWidget() self.widget.setLayout(layout) self.tree.setItemWidget(self, 1, self.widget) else: self.textbox = QLineEdit() #self.textbox.setStyleSheet("QLineEdit { border: none }"); self.tree.setItemWidget(self, 1, self.textbox) self.value = QSettings().value(self.paramName, defaultValue=param.defaultValue) self.textbox.setText(str(self.value))