QComboBox
has two signals, both called currentIndexChanged
; one passes the index of the selected item, and the other passes the text of the selected item. When I connect this signal to my slot, with something like self.myComboBox.currentIndexChanged.connect(self.mySlot)
it gives me an index. Is there a way I can use new-style signals to indicate that I want the text returned?
See the second example in connecting signals portion of documentation.
In your case it would be:
self.myComboBox.currentIndexChanged[QtCore.QString].connect(self.mySlot)
or if you are using v2 API for QString
self.myComboBox.currentIndexChanged[str].connect(self.mySlot)
You must specify the return value within brackets if you want non-default value to be returned
self.myComboBox.currentIndexChanged[str].connect(self.mySlot)
def mySlot(self, item):
self.currentItem = item
see : http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/new_style_signals_slots.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With