[PyKDE] Newbie question on QWidget.focusOutEvent

Volker Lenhardt volker.lenhardt at uni-due.de
Fri Sep 23 07:01:49 BST 2005


I'm new to Python and Qt.

My environment: Zaurus PDA, Qt/Embedded 2.3.10, Python 2.4.1

I try to use the moment when the focus changes from one combobox to 
another. As far as I understand the reference documentation there are 
the QWidget.focusInEvent and focusOutEvent.

But I don't get it to work. I try to open a message box on focus change, 
but it never comes. Focus changes undisturbed. A snippet of my script:

class DlgTourn(QDialog):
     def __init__(self, tourn):
     QDialog.__init__(self, None, None, True, 1)
     self.playerList=self._getList()

     self.layout=QVBoxLayout(self)
     self.inputLayout=QGridLayout(self.layout, 1, 1, 5)

     self.nCombo=Combo(0, True, self)
     for t in self.playerList:
         self.nCombo.insertItem(t, -1)
     self.inputLayout.addWidget(self.nCombo, 4, 1)

class Combo(QComboBox):
     def __init__(self, p, *args):
     QComboBox.__init__(self, *args)
     self.p=p

     def focusOutEvent(self, e):
     if e.lostFocus():
         QMessageBox.information(self, "Info", str(self.p))
         QComboBox.focusOutEvent(self, e)

What is wrong?

Volker

-- 
Volker Lenhardt
Am Spinnweg 19, 45894 Gelsenkirchen-Buer
Tel.: 0209/30213
E-Mail: volker.lenhardt at uni-duisburg-essen.de




More information about the PyQt mailing list