[PyQt] How do I subclass QTextEdit without warnings on close?
Brad Ralph
lists at ralph.id.au
Mon May 2 11:39:33 BST 2011
Hello,
I am trying to subclass QTextEdit to implement a foucsOutEvent. I must be
doing something wrong however because when I replace the standard QTextEdit
with my subclass I get the following error mesages when I close the program.
(once for each instance of my subclass). I don't when a reqular QTextEdit is
used.
Application asked to unregister timer 0x6000001 which is not registered in
this thread. Fix application.
Application asked to unregister timer 0x3d000002 which is not registered in
this thread. Fix application.
I running on Fedora 14 and my versions numbers are:
Python: 2.7
Qt: 4.7.2
PyQt: 4.8.3
sip: 4.12.1
Can anyone tell me what I'm doing wrong?
Below is a simple program to demonstrate my error:
########################################
#!/bin/env python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class MyQTextEdit(QtGui.QTextEdit):
textEdited = QtCore.pyqtSignal('QString')
def __init__(self, *args):
QtGui.QTextEdit.__init__(self, *args)
def focusOutEvent(self, e):
val = self.toHtml()
self.textEdited.emit(val)
class frmTest(QtGui.QMainWindow):
def __init__(self, app, *args):
QtGui.QMainWindow.__init__(self, *args)
self.app = app
self.mainWidget = QtGui.QFrame()
self.setCentralWidget(self.mainWidget)
self.fmeLayout = QtGui.QVBoxLayout(self.mainWidget)
self.teDesc1 = MyQTextEdit(self.mainWidget)
self.teDesc1.setObjectName(_fromUtf8("teDesc1"))
self.fmeLayout.addWidget(self.teDesc1)
self.teDesc2 = MyQTextEdit(self.mainWidget)
self.teDesc2.setObjectName(_fromUtf8("teDesc1"))
self.fmeLayout.addWidget(self.teDesc2)
if "__main__"==__name__:
qapp = QtGui.QApplication(sys.argv)
view = frmTest(qapp)
view.show()
qapp.exec_()
#####################################
Regards,
Brad Ralph
More information about the PyQt
mailing list