[PyQt] QComboBox don't emit signal into a dialog box
Vincent Vande Vyvre
vincent.vandevyvre at swing.be
Thu Oct 17 10:51:21 BST 2013
Le 17/10/2013 11:38, Phil Thompson a écrit :
> On Thu, 17 Oct 2013 11:20:43 +0200, Vincent Vande Vyvre
> <vincent.vandevyvre at swing.be> wrote:
>> When placed into a dialog box the QComboBox don't emit any signal if the
>> user activate it.
>>
>> When the current item is changed by the program, the signal is correctly
>> emitted.
>>
>> Python 2.7, Qt: 4.8.1, PyQt: 4.9.1
>> Python 3.2, Qt: 4.8.1, PyQt: 4.9.1
>>
>> Example
>>
>> from PyQt4 import QtGui
>>
>> class Editor(object):
>> def __init__(self, Dial):
>> super(Editor, self).__init__()
>> self.grid = QtGui.QGridLayout(Dial)
>> self.cmb = QtGui.QComboBox(Dial)
>> self.grid.addWidget(self.cmb, 0, 0, 1, 1)
>> self.cmb.addItems(['One', 'Two', 'Three'])
>> self.cmb.currentIndexChanged.connect(self.index_changed)
>> self.cmb.activated.connect(self.index_changed)
>> self.btn = QtGui.QPushButton('Quit', Dial)
>> self.grid.addWidget(self.btn, 1, 0, 1, 1)
>> self.btn.clicked.connect(Dial.accept)
>>
>> self.cmb.setCurrentIndex(1)
>>
>> def index_changed(self, idx):
>> print('Index:', idx)
>>
>> app = QtGui.QApplication([])
>> Dial = QtGui.QDialog()
>> Editor(Dial)
>> reply = Dial.exec_()
>>
>> With Qt: 5.0.2 + PyQt: 5.0 no problem, that's works.
> Keep a reference to your Editor instance.
>
> Phil
>
You'r right, that's works.
Strange behavior ...
Thank's
@ Sebastian, no, object or QObject don't change anything.
--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
More information about the PyQt
mailing list