how to selectall text inside an editable QComboBox (pyqt or pyside)
-
I am trying to create a combobox that has font sizes in it. similar to microsoft word fontsize combobox.
i just would like to know, how do you select all the text inside an editable combobox when the user clicks on it?this does not seem to work:
self.font_size_combo_box.lineEdit().selectAlland also this:
self.font_size_combo_box.lineEdit().setCursorPosition(0)thanks in advance. i really have no idea how to have the text in the comboBox be selected whenever user clicks in the comboBox.
def prevent_null_entry(self): any_unique_value = 1 validation_rule = QDoubleValidator(1,99,0) print(validation_rule.validate(self.font_size_combo_box.currentText(),any_unique_value)) if validation_rule.validate(self.font_size_combo_box.currentText(), any_unique_value)[0] == QValidator.Acceptable: self.font_size_combo_box.lineEdit().setCursorPosition(0) else: # message box warning qtw.QMessageBox.warning(self,"Can't leave this input field blank","Please type-in your desired font size between [1 to 99]",qtw.QMessageBox.StandardButton.Ok) self.font_size_combo_box.lineEdit().selectAll self.font_size_combo_box.setCurrentText(str(13))
-
I am trying to create a combobox that has font sizes in it. similar to microsoft word fontsize combobox.
i just would like to know, how do you select all the text inside an editable combobox when the user clicks on it?this does not seem to work:
self.font_size_combo_box.lineEdit().selectAlland also this:
self.font_size_combo_box.lineEdit().setCursorPosition(0)thanks in advance. i really have no idea how to have the text in the comboBox be selected whenever user clicks in the comboBox.
def prevent_null_entry(self): any_unique_value = 1 validation_rule = QDoubleValidator(1,99,0) print(validation_rule.validate(self.font_size_combo_box.currentText(),any_unique_value)) if validation_rule.validate(self.font_size_combo_box.currentText(), any_unique_value)[0] == QValidator.Acceptable: self.font_size_combo_box.lineEdit().setCursorPosition(0) else: # message box warning qtw.QMessageBox.warning(self,"Can't leave this input field blank","Please type-in your desired font size between [1 to 99]",qtw.QMessageBox.StandardButton.Ok) self.font_size_combo_box.lineEdit().selectAll self.font_size_combo_box.setCurrentText(str(13))
@adfinem_rising said in how to selectall text inside an editable QComboBox (pyqt or pyside):
self.font_size_combo_box.lineEdit().selectAll
I don't know about your whole question [actually this might be the answer], but since that's a function call you need to add the
()
.... -
@adfinem_rising said in how to selectall text inside an editable QComboBox (pyqt or pyside):
self.font_size_combo_box.lineEdit().selectAll
I don't know about your whole question [actually this might be the answer], but since that's a function call you need to add the
()
....@JonB OMG!!! hahaha that was the answer all along?! i was sitting here wondering why it was not working!! thanks!!
-
@JonB OMG!!! hahaha that was the answer all along?! i was sitting here wondering why it was not working!! thanks!!
@adfinem_rising
Does Python not warn you about accidentally using a function on a statement of its own without the()
s? Else it's going to be a pretty common gotcha.... -
@adfinem_rising
Does Python not warn you about accidentally using a function on a statement of its own without the()
s? Else it's going to be a pretty common gotcha....@JonB not really, im using visual studio code and it does not say anything to me. it just doesn't give an error and the application does not crash. so i couldn't understand what was happening. thanks again for the answer, i spent the wholeday googling. who knows maybe i would have been googling for a month and still not get a solution lol
i got that selectall code from stackoverflow and it didnt have the () at the end