Reputation: 4903
this could sound strange and it is more a curiosity then a question.
I have a simple combobox with 2 elements in Qt Designer.
The 2 combobox elements are vertical
and horizontal
but for the script I'm writing I need to get only v
or h
.
Usually I easily do it with a loop like:
name = self.combbox.currentText()
if name == 'vertical':
name = 'v'
else:
name = 'h'
and that's ok.
I was just thinking if there is a way in Qt Designer to assign a kind of tag
to the elements so the user sees the complete text but with the code it can be retrieved the tag
.
Thanks to all
Upvotes: 1
Views: 1321
Reputation: 1087
I don't believe you can do this with Qt Designer alone (see How can I add item data to QComboBox from Qt Designer/.ui file).
With some extra Python, though, you can add use setItemData()
to add whatever extra data you want (How can I get the selected VALUE out of a QCombobox?) and retrieve it with itemData()
and currentIndex()
.
Upvotes: 2