[PyKDE] (no subject)
ankarp at charter.net
ankarp at charter.net
Thu Feb 26 07:54:01 GMT 2004
Hello to all,
While playing with PyQt, I attempted to reimplement
in it a few C++ examples from the Qt distribution.
Working on the example from
<...>/qt-devel-XXX/examples/mdi
(which compiles and runs properly in C++) I encountered
the following problem, shown here in the most minimal
form for illustration:
##########################
import sys
from qt import *
class ApplicationWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self,None,
"example application main window",
Qt.WDestructiveClose)
self.fileTools = QToolBar(self, "file operations")
self.addDockWindow(self.fileTools,
"File operations",
QMainWindow.DockTop, True)
openIcon = QPixmap([]) # empty pixmap, for brevity
openIconSet = QIconSet(openIcon)
fileOpen = QToolButton(openIconSet, "Open File",
None, self, SLOT("load()"), self.fileTools,
"open file" )
def load(self):
print "DEBUG: called load()..."
def main(argv):
app=QApplication(sys.argv)
window=ApplicationWindow()
window.show()
app.connect(app, SIGNAL('lastWindowClosed()'), app,
SLOT('quit()'))
app.exec_loop()
if __name__=="__main__":
main(sys.argv)
##########################################
When running it I get a window show up fine, but
also the following messages:
bash$ python mdimin.py
QObject::connect: No such slot QMainWindow::load()
QObject::connect: (sender name: 'open file')
QObject::connect: (receiver name: 'example application main window')
In other words, self is not recognized as having type
ApplicationWindow. Does anybody know how to fix this?
The same error occurs when I try to connect to the slot
in other ways, for example, while still in ApplicationWindow.__init__():
file = QPopupMenu(self)
id = file.insertItem( openIconSet, "&Open...",
self, SLOT("load()"),
Qt.CTRL+Qt.Key_O )
Additional info: this is PyQt-3.10, Qt version 3,
on Redhat 9 (kernel 2.4.20)
Thanks for any help!
--Anatoly
More information about the PyQt
mailing list