1

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

eclarkso
  • 1,087
  • 9
  • 21
matteo
  • 4,683
  • 9
  • 41
  • 77

1 Answers1

2

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().

Community
  • 1
  • 1
eclarkso
  • 1,087
  • 9
  • 21
  • thanks for the answer.. Well in my case it is easier to loop and re-assign the values.. Anyway, thanks! – matteo May 24 '16 at 13:53