Thanks Oleh Prypin! Your answer helped me when I came across the obscure arg__1 in the PySide documentation.
When I tested both combo.currentIndexChanged[str] and combo.currentIndexChanged[unicode], each signal sent the unicode version of the current index text.
Here's an example that demonstrates the behavior:
from PySide import QtCore
from PySide import QtGui
class myDialog(QtGui.QWidget):
def __init__(self, *args, **kwargs):
super(myDialog, self).__init__(*args, **kwargs)
combo = QtGui.QComboBox()
combo.addItem('Dog', 'Dog')
combo.addItem('Cat', 'Cat')
layout = QtGui.QVBoxLayout()
layout.addWidget(combo)
self.setLayout(layout)
combo.currentIndexChanged[int].connect(self.intChanged)
combo.currentIndexChanged[str].connect(self.strChanged)
combo.currentIndexChanged[unicode].connect(self.unicodeChanged)
combo.setCurrentIndex(1)
def intChanged(self, index):
print "Combo Index: "
print index
print type(index)
def strChanged(self, value):
print "Combo String:"
print type(value)
print value
def unicodeChanged(self, value):
print "Combo Unicode String:"
print type(value)
print value
if __name__ == "__main__":
app = QtGui.QApplication([])
dialog = myDialog()
dialog.show()
app.exec_()
The resulting output is:
Combo Index
1
<type 'int'>
Combo String
<type 'unicode'>
Cat
Combo Unicode String
<type 'unicode'>
Cat
I also confirmed that basestring will throw an error IndexError: Signature currentIndexChanged(PyObject) not found for signal: currentIndexChanged
. PySide appears to differentiate int
, float
(which it refers to as double
), str
/unicode
(which both become unicode
), and bool
, but all other python types are parsed as PyObject
for the purpose of signal signatures.
Hope that helps someone!